[ 
https://issues.apache.org/jira/browse/CAMEL-25493?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Federico Mariani reassigned CAMEL-25493:
----------------------------------------

    Assignee: Federico Mariani

> camel-yaml-io - YAML route dump drops a top-level errorHandler
> --------------------------------------------------------------
>
>                 Key: CAMEL-25493
>                 URL: https://issues.apache.org/jira/browse/CAMEL-25493
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jbang, camel-yaml-dsl
>    Affects Versions: 4.22.1
>            Reporter: Federico Mariani
>            Assignee: Federico Mariani
>            Priority: Major
>
> {{camel validate normalize}} (the YAML route dump, 
> {{camel.main.dumpRoutes=yaml}}) drops a top-level {{errorHandler}}: the 
> normalized file loads and validates, but the routes silently lose their error 
> handler (here a dead letter channel falls back to the default error handler).
> h3. Reproduction (Camel CLI 4.22.1, same on main)
> {code:yaml|title=in.yaml}
> - errorHandler:
>     deadLetterChannel:
>       deadLetterUri: log:dead
> - route:
>     id: myRoute
>     from:
>       uri: direct:start
>       steps:
>         - to: log:out
> {code}
> {{camel validate normalize in.yaml}}:
> {code:yaml}
> - route:
>     id: myRoute
>     from:
>       uri: direct
>       parameters:
>         name: start
>       steps:
>         - to:
>             uri: log
>             parameters:
>               loggerName: out
> {code}
> No error is reported; the {{errorHandler}} is gone.
> h3. Cause
> The YAML DSL loader passes a top-level {{errorHandler}} to 
> {{RouteBuilder.errorHandler(ErrorHandlerFactory)}} 
> ({{YamlRoutesBuilderLoader}}), and {{RoutesDefinition.route(...)}} sets it on 
> each route with {{RouteDefinition.setErrorHandlerFactoryIfNull}}. That sets 
> only the {{errorHandlerFactory}} field, not the {{errorHandler}} 
> ({{ErrorHandlerDefinition}}) property, and the YAML writer 
> ({{YamlModelWriter.doWriteRouteDefinition}}) writes only 
> {{getErrorHandler()}}. A route level {{errorHandler}} set with 
> {{setErrorHandler}} is written; the builder level one is not.
> A fix could write the error handler factory of the routes, when it is a model 
> {{ErrorHandlerDefinition}} that was not set on the route itself, as a 
> top-level {{errorHandler}} (once, as for the onException of CAMEL-25490).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to