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

   ## Summary
   
   `XmlSourceHandlerFactoryImpl.getSource(Exchange, Expression)` checked 
`isInputStreamNeeded(exchange)` against the **message body** before evaluating 
the configured `source` expression. When the body was an `InputStream`, 
`StreamCache`, or any type without a direct `Source` converter — which is the 
common case with `file`, `http`, `ftp`, `netty` consumers or stream caching — 
`source=header:x` / `source=variable:x` / `source=property:x` silently 
transformed the **body** instead of the configured source. No error, wrong 
output.
   
   ### Fix
   
   Evaluate the `source` expression **first** when it is configured, and pass 
the result directly to the type-based conversion method. The 
`isInputStreamNeeded` optimization is only applied when no source expression is 
configured (i.e. the body is the intended input).
   
   This follows the same pattern already used by `JsonSourceHandlerFactoryImpl` 
in `camel-xj`, which correctly evaluates the `source` expression before 
handling by type.
   
   ### Affected components
   
   - `xslt` — fix in `XmlSourceHandlerFactoryImpl`
   - `xslt-saxon` — inherits the fix (does not override `getSource(Exchange, 
Expression)`)
   - `xj` (XML→JSON) — **not affected** (already correct)
   
   ### Tests
   
   Added `XsltSaxonSourceInputStreamBodyTest` with 5 tests covering:
   - `source=header` with `InputStream` body
   - `source=variable` with `InputStream` body
   - `source=property` with `InputStream` body
   - `source=header` with stream caching enabled (body wrapped as `StreamCache`)
   - `source=variable` with stream caching enabled
   
   _Claude Code on behalf of davsclaus_


-- 
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