This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch camel-3.21.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit 26abf18c3bd667114b4b4e14ca7526da809319e3 Author: Otavio Rodolfo Piske <angusyo...@gmail.com> AuthorDate: Mon Jul 31 14:28:50 2023 +0200 CAMEL-19675: fixed not copying safe copy properties This could cause it to lose attachments when using multicast EIP It adapts the patch fc0981455208ef91da94d56ece7c9d7b539020eb from Camel 4 to Camel 3. --- core/camel-api/src/main/java/org/apache/camel/ExtendedExchange.java | 6 ++++++ .../src/main/java/org/apache/camel/support/AbstractExchange.java | 6 ++++++ .../src/main/java/org/apache/camel/support/ExchangeHelper.java | 1 + 3 files changed, 13 insertions(+) diff --git a/core/camel-api/src/main/java/org/apache/camel/ExtendedExchange.java b/core/camel-api/src/main/java/org/apache/camel/ExtendedExchange.java index 929b7c0a943..5f8e1f6ef4f 100644 --- a/core/camel-api/src/main/java/org/apache/camel/ExtendedExchange.java +++ b/core/camel-api/src/main/java/org/apache/camel/ExtendedExchange.java @@ -239,4 +239,10 @@ public interface ExtendedExchange extends Exchange { * @see SafeCopyProperty */ <T> T getSafeCopyProperty(String key, Class<T> type); + + /** + * Copy the safe copy properties from this exchange to the target exchange + */ + void copySafeCopyPropertiesTo(ExtendedExchange target); + } 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 6e480f18227..92bd3aec906 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 @@ -210,6 +210,12 @@ class AbstractExchange implements ExtendedExchange { }); } + @Override + public void copySafeCopyPropertiesTo(ExtendedExchange target) { + safeCopyProperties.entrySet() + .forEach(entry -> target.setSafeCopyProperty(entry.getKey(), entry.getValue().safeCopy())); + } + @Override public CamelContext getContext() { return context; diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java index de09fa7238f..1ae4a687384 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/ExchangeHelper.java @@ -390,6 +390,7 @@ public final class ExchangeHelper { result.getProperties().putAll(source.getProperties()); } source.adapt(ExtendedExchange.class).copyInternalProperties(result); + source.adapt(ExtendedExchange.class).copySafeCopyPropertiesTo(result); // copy over state result.setRouteStop(source.isRouteStop());