[
https://issues.apache.org/jira/browse/CAMEL-27727?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-27727:
--------------------------------
Fix Version/s: 4.25.0
(was: 4.24.0)
> camel-dataformat: URI parameters change a shared registry bean; bean use
> depends on order
> -----------------------------------------------------------------------------------------
>
> Key: CAMEL-27727
> URL: https://issues.apache.org/jira/browse/CAMEL-27727
> Project: Camel
> Issue Type: Bug
> Reporter: Claus Ibsen
> Priority: Minor
> Fix For: 4.25.0
>
>
> Found while improving the option descriptions of camel-dataformat for
> CAMEL-23832 (commit
> https://github.com/apache/camel/commit/eda20490b635281624aaa61da69330ca75f9effd).
> These are separate problems of the component; the descriptions commit only
> documents the current behavior.
> h4. 1. Endpoint URI parameters change a shared DataFormat bean of the registry
> {{DataFormatComponent.createEndpoint()}} first calls
> {{CamelContext.createDataFormat(name)}}. When that returns null (no
> {{DataFormatFactory}}, no service file and no class of that name), it falls
> back to {{CamelContext.resolveDataFormat(name)}}, which returns the
> DataFormat bean of the registry, the same instance that the context caches
> and that the marshal and unmarshal EIPs and other endpoints use.
> The endpoint URI parameters are then bound onto that shared instance with
> {{PropertyBindingSupport}}. Two endpoints such as
> {{dataformat:myFormat:marshal?a=1}} and {{dataformat:myFormat:unmarshal?a=2}}
> overwrite each other, and the last one created wins for every user of the
> bean.
> Proposed change: do not bind URI parameters onto a data format that the
> endpoint did not create (fail, or warn, when parameters are given), or
> document that the bean is shared.
> h4. 2. A DataFormat bean with the name of a built-in data format is used only
> if something resolved it before
> For a name such as {{csv}} with camel-csv on the classpath,
> {{createDataFormat(name)}} always creates a new instance, so a DataFormat
> bean named {{csv}} in the registry is not used by {{dataformat:csv:marshal}},
> while {{marshal().custom("csv")}} uses the bean.
> {{DataFormatComponent.copyGlobalConfiguration()}} copies the options of the
> bean onto the new instance only when {{getDataFormatNames()}} already
> contains the name, that is when the global configuration or another route
> resolved it before this endpoint was created. So whether the bean's settings
> apply depends on the order in which routes and endpoints are created.
> Proposed change: look up a DataFormat bean of that name first (as the EIPs
> do), or always copy its options; then the result does not depend on the
> creation order.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)