oscerd opened a new pull request, #24050:
URL: https://github.com/apache/camel/pull/24050

   ## Summary
   
   `dataformat:` component endpoints (e.g. `to("dataformat:beanio:unmarshal")`) 
ignored the global `camel.dataformat.<name>.*` configuration from 
`application.properties`, while the equivalent fluent DSL 
(`unmarshal().beanio(...)`) already honored it. The two paths behaved 
inconsistently, and the component path could throw at runtime (e.g. 
`IllegalArgumentException: Stream name not configured` for BeanIO).
   
   Reported while analysing 
[camel-quarkus#7651](https://github.com/apache/camel-quarkus/issues/7651); the 
root cause is in Camel core.
   
   ## Root cause
   
   `DataFormatComponent.createEndpoint()` calls `createDataFormat(name)`, which 
returns a fresh, **unconfigured** instance, and then binds only the endpoint 
URI parameters. It never copies the options of the auto-configured "template" 
data format (the one set up from `camel.dataformat.<name>.*`, resolvable via 
`resolveDataFormat(name)` and listed in `getDataFormatNames()`).
   
   `DataFormatReifier.configureDataFormat()` already does this for the 
`marshal()`/`unmarshal()` DSL path (CAMEL-22352), but the component uses a 
different code path that was never updated.
   
   ## Fix
   
   When the component creates a brand-new data format instance, it now harvests 
the auto-configured template's option values (via the same 
`ExtendedPropertyConfigurerGetter` mechanism the reifier uses) and binds them 
onto the new instance **before** binding the endpoint URI parameters — so URI 
parameters keep precedence over the global configuration. The shared template 
instance itself is never mutated.
   
   The change is intentionally contained to `camel-dataformat`. 
`AbstractCamelContext.createDataFormat()` is deliberately left unchanged, since 
it must keep returning a clean instance for the reifier and other callers.
   
   ## Tests
   
   Added `DataFormatComponentConfigTest` in `camel-csv` (mirroring the 
CAMEL-22352 `MainCsvTest`): a `Main`-based route using 
`to("dataformat:csv:unmarshal")` with 
`camel.dataformat.csv.ignore-surrounding-spaces=true` in 
`application.properties`. It asserts the global option is applied (surrounding 
spaces stripped) — this fails without the fix and passes with it. The existing 
`MainCsvTest` (reifier path) still passes.
   
   ## Docs
   
   Added a `camel-dataformat` entry to the 4.21 upgrade guide describing the 
behavior alignment.
   
   ## Build
   
   Full-reactor `mvn clean install -Dquickly` passes. No generated/catalog/DSL 
files changed (there is no `@UriParam` surface change).
   
   ---
   _Claude Code on behalf of Andrea Cosentino_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to