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

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 7747c101eeb CAMEL-19801: fixed missing deep-copy (#11333)
7747c101eeb is described below

commit 7747c101eeb9fa61dc22be897af4876c93651dde
Author: Otavio Rodolfo Piske <orpi...@users.noreply.github.com>
AuthorDate: Thu Sep 7 10:48:55 2023 +0200

    CAMEL-19801: fixed missing deep-copy (#11333)
    
    This should fix WireTapTest in camel-attachments, which relies on deep 
copies to work
---
 .../java/org/apache/camel/support/AbstractExchange.java    | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/AbstractExchange.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/AbstractExchange.java
index ac2824eda19..42ff7b76398 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/AbstractExchange.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/AbstractExchange.java
@@ -133,7 +133,7 @@ abstract class AbstractExchange implements Exchange {
         }
 
         if (parent.hasSafeCopyProperties()) {
-            this.safeCopyProperties = parent.getSafeCopyProperties();
+            this.safeCopyProperties = parent.copySafeCopyProperties();
         }
     }
 
@@ -381,11 +381,13 @@ abstract class AbstractExchange implements Exchange {
         return properties;
     }
 
-    Map<String, SafeCopyProperty> getSafeCopyProperties() {
-        if (safeCopyProperties == null) {
-            this.safeCopyProperties = new ConcurrentHashMap<>(2);
+    private Map<String, SafeCopyProperty> copySafeCopyProperties() {
+        Map<String, SafeCopyProperty> copy = new ConcurrentHashMap<>();
+        for (Map.Entry<String, SafeCopyProperty> entry : 
this.safeCopyProperties.entrySet()) {
+            copy.put(entry.getKey(), entry.getValue().safeCopy());
         }
-        return safeCopyProperties;
+
+        return copy;
     }
 
     @Override
@@ -683,7 +685,7 @@ abstract class AbstractExchange implements Exchange {
         if (!hasSafeCopyProperties()) {
             return null;
         }
-        Object value = getSafeCopyProperties().get(key);
+        Object value = safeCopyProperties.get(key);
 
         if (type.isInstance(value)) {
             return (T) value;

Reply via email to