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

Claus Ibsen closed CAMEL-24052.
-------------------------------
    Resolution: Fixed

Fixed via https://github.com/apache/camel/pull/24662 (merged to main)

> dumpModelAsXml permanently destroys EndpointDSL builders on RouteDefinition
> ---------------------------------------------------------------------------
>
>                 Key: CAMEL-24052
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24052
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-xml-io
>    Affects Versions: 4.21.0
>            Reporter: Federico Mariani
>            Assignee: Federico Mariani
>            Priority: Minor
>             Fix For: 4.22.0
>
>
> {{LwModelToXMLDumper.resolveEndpointDslUris()}} mutates the live 
> {{RouteDefinition}} when serializing it to XML for logging. It calls 
> {{from.setUri(rawUri)}} and {{to.setUri(rawUri)}} on the live 
> {{FromDefinition}}/{{SendDefinition}} objects, which internally call 
> {{clear()}}, permanently nulling the 
> {{endpointConsumerBuilder}}/{{endpointProducerBuilder}} fields and replacing 
> them with a plain URI string.
> For endpoints with non-primitive builder properties (e.g. a custom 
> {{S3Client}}, {{ExceptionHandler}}, or similar bean injected via 
> {{advanced().xxx(myBean)}}), {{getRawUri()}} without a {{CamelContext}} can 
> only produce a URI with a {{?hash=XXXXXXXX}} parameter. After the mutation, 
> Camel no longer resolves the original bean reference and falls back to a 
> default (unconfigured) client, causing route startup failures.
> h3. Affected paths
> | Dumper | Module | Triggered by |
> | {{LwModelToXMLDumper}} | {{camel-xml-io}} | {{AdviceWith.adviceWith()}} 
> (logXml=true, the default), JMX {{dumpRoutesAsXml}}, startup dump strategy |
> | {{JaxbModelToXMLDumper}} | {{camel-xml-jaxb}} | Same JMX and dump strategy 
> paths, when JAXB is on the classpath |
> | {{LwModelToYAMLDumper}} | {{camel-yaml-io}} | Any YAML dump of live routes |
> | {{LwModelToJavaDumper}} | {{camel-java-io}} | Any Java DSL dump of live 
> routes |
> h3. Reproducer
> A route built with {{EndpointRouteBuilder}} that injects a custom bean into 
> an endpoint via the Endpoint DSL (e.g. 
> {{aws2S3("bucket").advanced().amazonS3Client(myClient)}}). Calling 
> {{AdviceWith.adviceWith(context, "route-id", ...)}} then fails with:
> {noformat}
> Failed to resolve endpoint: aws2-s3://bucket?hash=20810451 due to: 
> AmazonS3Client or accessKey and secretKey must be specified
> {noformat}
> h3. Workaround
> Pass {{logXml=false}} to {{adviceWith()}}.
> h3. Root Cause
> {{resolveEndpointDslUris()}} in {{LwModelToXMLDumper}} calls {{setUri()}} on 
> live model objects before XML serialization but never restores the original 
> builder references afterward.



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

Reply via email to