This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-4.10.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.10.x by this push:
     new e19f6b37900 CAMEL-21755: Adjust attachments API on Message to avoid 
issue during routing
e19f6b37900 is described below

commit e19f6b3790046142c556862e47a5860048baee0d
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Tue Feb 25 07:36:37 2025 +0100

    CAMEL-21755: Adjust attachments API on Message to avoid issue during routing
---
 .../main/java/org/apache/camel/language/groovy/GroovyExpression.java  | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git 
a/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyExpression.java
 
b/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyExpression.java
index c1e41ea75de..f9c7a38a228 100644
--- 
a/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyExpression.java
+++ 
b/components/camel-groovy/src/main/java/org/apache/camel/language/groovy/GroovyExpression.java
@@ -26,6 +26,7 @@ import groovy.lang.GroovyShell;
 import groovy.lang.Script;
 import org.apache.camel.Exchange;
 import org.apache.camel.attachment.AttachmentMessage;
+import org.apache.camel.attachment.DefaultAttachmentMessage;
 import org.apache.camel.support.ExchangeHelper;
 import org.apache.camel.support.ExpressionSupport;
 import org.apache.camel.support.ObjectHelper;
@@ -92,7 +93,8 @@ public class GroovyExpression extends ExpressionSupport {
     protected Binding createBinding(Exchange exchange, Map<String, Object> 
globalVariables) {
         Map<String, Object> map = new HashMap<>(globalVariables);
         ExchangeHelper.populateVariableMap(exchange, map, true);
-        if (exchange.getMessage() instanceof AttachmentMessage am && 
am.hasAttachments()) {
+        AttachmentMessage am = new 
DefaultAttachmentMessage(exchange.getMessage());
+        if (am.hasAttachments()) {
             map.put("attachments", am.getAttachments());
         } else {
             map.put("attachments", Collections.EMPTY_MAP);

Reply via email to