camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [3/3] camel git commit: CAMEL-8073: Fixed Camel may clear attachments during routing. Thanks to Andrei M for a patch that I modified slightly.
Date Fri, 21 Nov 2014 15:02:55 GMT
CAMEL-8073: Fixed Camel may clear attachments during routing. Thanks to Andrei M for a patch
that I modified slightly.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8a50d427
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8a50d427
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8a50d427

Branch: refs/heads/camel-2.13.x
Commit: 8a50d4278ae40fab946e545845208a6d7774b760
Parents: 00c5178
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Nov 21 16:00:47 2014 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Nov 21 16:02:39 2014 +0100

----------------------------------------------------------------------
 .../org/apache/camel/impl/MessageSupport.java   | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8a50d427/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java b/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java
index c199a15..613d6a0 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java
@@ -151,12 +151,22 @@ public abstract class MessageSupport implements Message {
                 getHeaders().putAll(that.getHeaders());
             }
         }
-        
-        if (hasAttachments()) {
-            getAttachments().clear();
+
+        // the attachments may be the same instance if the end user has made some mistake
+        // and set the OUT message with the same attachment instance of the IN message etc
+        boolean sameAttachments = false;
+        if (hasAttachments() && that.hasAttachments() && getAttachments()
== that.getAttachments()) {
+            sameAttachments = true;
         }
-        if (that.hasAttachments()) {
-            getAttachments().putAll(that.getAttachments());
+
+        if (!sameAttachments) {
+            if (hasAttachments()) {
+                // okay its safe to clear the attachments
+                getAttachments().clear();
+            }
+            if (that.hasAttachments()) {
+                getAttachments().putAll(that.getAttachments());
+            }
         }
     }
 


Mime
View raw message