Federico Mariani created CAMEL-24052:
----------------------------------------
Summary: 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
{{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. Trigger
Any call that invokes the XML dumper on a live route, most commonly
{{AdviceWith.adviceWith()}} with the default {{logXml=true}}.
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)