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

   Fixes [CAMEL-26499](https://issues.apache.org/jira/browse/CAMEL-26499). 
Follow-up of CAMEL-26062 (#28890).
   
   ### 1. `SourceConverter.toURISource` fails for a remote file
   
   **What was wrong:** the `WrappedFile` to Smooks `Source` converter cast 
`getBody()` to `java.io.File`. A remote file (ftp, sftp, ftps) holds an 
FTP/SFTP file object and its downloaded content as body (for example a 
`byte[]`), so `convertBodyTo(Source.class)` failed with a `ClassCastException`. 
#28890 fixed the same cast in `SmooksProcessor`, but not in this converter.
   
   **What changed:** the converter now takes the `Exchange`, like the 
converters of camel-file. It does the same as `SmooksProcessor` since #28890:
   - `getFile()` is a `java.io.File`: read from its URL (a `URLSource`), as 
before.
   - otherwise (remote file): read the downloaded content as an `InputStream` 
(a `StreamSource`). The camel-file converter loads the content first.
   - with no exchange, a remote file returns `null` (no conversion), like the 
camel-file `GenericFile` to `InputStream` converter.
   
   `SourceConverterLoader` is regenerated for the new signature.
   
   **Tests:** `SmooksReaderBodyTest` has two new tests that convert a local and 
a remote `GenericFile` with `convertBodyTo(Source.class)` before the Smooks 
endpoint. The remote file test fails before the fix with the 
`ClassCastException`. The local file test passes before and after and guards 
the local file case.
   
   ### 2. `BeanRouter` with a correlation id does not set 
`CamelSmooksExecutionContext`
   
   **What was wrong:** the branch without a correlation id sends the bean with 
the `CamelSmooksExecutionContext` header. The branch with a correlation id only 
set the correlation id header.
   
   **What changed:** the branch with a correlation id also sets the 
`CamelSmooksExecutionContext` header.
   
   **Tests:** 
`BeanRouterTest.testBeanRouterWithCorrelationIdAddsCamelSmooksExecutionContextHeader`
 checks the body, the correlation id header and the execution context header. 
It fails before the fix ("No header with name CamelSmooksExecutionContext 
found").
   
   ### Notes
   
   - All 58 tests of camel-smooks pass (`mvn clean install -Psourcecheck`).
   - No doc or upgrade guide change: the doc already says a remote file body is 
read, and the header is documented. Both are bug fixes.
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 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