allthingssecurity opened a new pull request, #28531: URL: https://github.com/apache/camel/pull/28531
# Description [CAMEL-25951](https://issues.apache.org/jira/browse/CAMEL-25951) When an exchange is sent InOut to a jms or sjms endpoint, the reply manager sets the reply as a new OUT message: `exchange.setOut(new JmsMessage(...))` in camel-jms `ReplyManagerSupport.handleSuccessfulReply`, and the same with `SjmsMessage` in camel-sjms. The attachments of a message are its `MessageTrait.ATTACHMENTS` payload, and the new reply message does not have it. So the exchange loses its attachments after every request/reply. For example, a route that receives a mail with attachments, asks a JMS service for something (InOut) and then forwards the mail sends it without the attachments. Nothing is logged. CAMEL-21755 (4.10.1) moved the attachments from exchange properties into the message trait. CAMEL-24365 (4.22) then copied them into an OUT message created by `exchange.getOut()`, so that camel-http and other producers keep them. Its upgrade guide entry describes that as restoring the pre-4.10.1 behaviour. The JMS and SJMS reply managers do not use `exchange.getOut()`, so they still drop the attachments. CAMEL-25779 (#28083) fixed another path of the same change, in `JmsMessage.copyFrom`. Changes: - `ReplyManagerSupport.handleSuccessfulReply` in camel-jms and camel-sjms copies the `ATTACHMENTS` trait of the IN message into the reply message before `exchange.setOut(response)`, the same way as `AbstractExchange.newOutMessage`. - camel-amqp uses the camel-jms reply manager, so it is fixed as well. - A request without attachments gets a reply without the trait, as before. - No option or generated file change. No upgrade guide entry: this is the behaviour that the 4.22 guide already describes for `exchange.getOut()`. I can add a line under camel-jms if wanted. - Backport: camel-4.23.x and 4.22.x have the same reply managers. camel-4.18.x and 4.14.x have them too, but they do not have the CAMEL-24365 change either. I read the code on those branches but did not run the tests there. Not changed (follow-up JIRAs if wanted): the producers of camel-netty (`ClientChannelHandler`) and camel-undertow (`UndertowClientCallback`) also set the response as a new message and drop the attachments. Tests: - New `JmsInOutKeepsAttachmentsTest` (camel-jms) and `SjmsInOutKeepsAttachmentsTest` (camel-sjms), 2 tests each, JUnit assertions as in the modules. They use the embedded in-VM Artemis broker of the other tests of these modules. A route sends InOut to a queue whose consumer answers with "Bye " + body. - `replyKeepsTheAttachmentsOfTheRequest` fails on main in both modules: `the reply must keep the attachments of the exchange ==> expected: not <null>`. - `replyToARequestWithoutAttachmentsHasNone` is a control that passes on main and with the fix. - Unit tests with the fix: - camel-jms: 478 run (three surefire executions: 456, 16 and 6), 0 failures, 11 skipped. - camel-sjms: 141 run, 0 failures, 5 skipped. - The formatter and import-sort plugins ran. I built offline with `-Dasm-version=9.11` because asm 9.11.1 was not in my local repository. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it): [CAMEL-25951](https://issues.apache.org/jira/browse/CAMEL-25951). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built camel-jms and camel-sjms and ran their tests, including the formatter and import-sort plugins. No generated file changes. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 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]
