gnodet-bot commented on code in PR #28531:
URL: https://github.com/apache/camel/pull/28531#discussion_r4383874452


##########
components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/ReplyManagerSupport.java:
##########
@@ -216,6 +219,13 @@ private void handleSuccessfulReply(ReplyHolder holder, 
Exchange exchange) {
         Message message = holder.getMessage();
         Session session = holder.getSession();
         JmsMessage response = new JmsMessage(exchange, message, session, 
endpoint.getBinding());
+        // keep the attachments of the exchange, as an OUT message created by 
exchange.getOut() does
+        @SuppressWarnings("unchecked")
+        Map<String, Object> attachments
+                = (Map<String, Object>) 
exchange.getIn().getPayloadForTrait(MessageTrait.ATTACHMENTS);
+        if (attachments != null) {
+            response.setPayloadForTrait(MessageTrait.ATTACHMENTS, new 
LinkedHashMap<>(attachments));
+        }
         exchange.setOut(response);

Review Comment:
   💡 **Nit:** `AbstractExchange.newOutMessage()` guards with 
`in.hasTrait(MessageTrait.ATTACHMENTS)` before calling `getPayloadForTrait`. 
The fix here skips that guard and relies solely on the `null` check. 
Functionally equivalent (since `getPayloadForTrait` returns `null` when no 
trait is set), but consider matching the canonical pattern for consistency:
   
   ```suggestion
           // keep the attachments of the exchange, as an OUT message created 
by exchange.getOut() does
           if (exchange.getIn().hasTrait(MessageTrait.ATTACHMENTS)) {
               @SuppressWarnings("unchecked")
               Map<String, Object> attachments
                       = (Map<String, Object>) 
exchange.getIn().getPayloadForTrait(MessageTrait.ATTACHMENTS);
               if (attachments != null) {
                   response.setPayloadForTrait(MessageTrait.ATTACHMENTS, new 
LinkedHashMap<>(attachments));
               }
           }
   ```



##########
components/camel-sjms/src/main/java/org/apache/camel/component/sjms/reply/ReplyManagerSupport.java:
##########
@@ -190,6 +193,13 @@ private void handleSuccessfulReply(ReplyHolder holder, 
Exchange exchange) {
         Message message = holder.getMessage();
         Session session = holder.getSession();
         SjmsMessage response = new SjmsMessage(exchange, message, session, 
endpoint.getBinding());
+        // keep the attachments of the exchange, as an OUT message created by 
exchange.getOut() does
+        @SuppressWarnings("unchecked")
+        Map<String, Object> attachments
+                = (Map<String, Object>) 
exchange.getIn().getPayloadForTrait(MessageTrait.ATTACHMENTS);
+        if (attachments != null) {
+            response.setPayloadForTrait(MessageTrait.ATTACHMENTS, new 
LinkedHashMap<>(attachments));
+        }
         exchange.setOut(response);

Review Comment:
   💡 **Nit:** Same consistency gap as `camel-jms`: add the `hasTrait` guard to 
match `AbstractExchange.newOutMessage()`.
   
   ```suggestion
           // keep the attachments of the exchange, as an OUT message created 
by exchange.getOut() does
           if (exchange.getIn().hasTrait(MessageTrait.ATTACHMENTS)) {
               @SuppressWarnings("unchecked")
               Map<String, Object> attachments
                       = (Map<String, Object>) 
exchange.getIn().getPayloadForTrait(MessageTrait.ATTACHMENTS);
               if (attachments != null) {
                   response.setPayloadForTrait(MessageTrait.ATTACHMENTS, new 
LinkedHashMap<>(attachments));
               }
           }
   ```



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