You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/07/31 08:33:12 UTC
[camel] branch main updated: CAMEL-19675: fixed not copying safe copy properties (#10888)
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 fc098145520 CAMEL-19675: fixed not copying safe copy properties (#10888)
fc098145520 is described below
commit fc0981455208ef91da94d56ece7c9d7b539020eb
Author: Otavio Rodolfo Piske <or...@users.noreply.github.com>
AuthorDate: Mon Jul 31 10:33:05 2023 +0200
CAMEL-19675: fixed not copying safe copy properties (#10888)
This could cause it to lose attachments when using multicast EIP
---
.../src/main/java/org/apache/camel/ExchangeExtension.java | 5 +++++
.../src/main/java/org/apache/camel/support/ExchangeHelper.java | 3 +++
.../java/org/apache/camel/support/ExtendedExchangeExtension.java | 7 +++++++
3 files changed, 15 insertions(+)
diff --git a/core/camel-api/src/main/java/org/apache/camel/ExchangeExtension.java b/core/camel-api/src/main/java/org/apache/camel/ExchangeExtension.java
index 8d412185d9f..60f625bba3f 100644
--- a/core/camel-api/src/main/java/org/apache/camel/ExchangeExtension.java
+++ b/core/camel-api/src/main/java/org/apache/camel/ExchangeExtension.java
@@ -217,6 +217,11 @@ public interface ExchangeExtension {
*/
void setSafeCopyProperty(String key, SafeCopyProperty value);
+ /**
+ * Copy the safe copy properties from this exchange to the target exchange
+ */
+ void copySafeCopyPropertiesTo(ExchangeExtension target);
+
/**
* Gets the internal properties from this exchange. The known set of internal keys is defined in
* {@link ExchangePropertyKey}.
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 69fdd23678c..3841061f1de 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
@@ -46,6 +46,7 @@ import org.apache.camel.NoSuchPropertyException;
import org.apache.camel.NoTypeConversionAvailableException;
import org.apache.camel.Route;
import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.SafeCopyProperty;
import org.apache.camel.TypeConversionException;
import org.apache.camel.WrappedFile;
import org.apache.camel.spi.NormalizedEndpointUri;
@@ -383,6 +384,7 @@ public final class ExchangeHelper {
result.getProperties().putAll(source.getProperties());
}
source.getExchangeExtension().copyInternalProperties(result);
+ source.getExchangeExtension().copySafeCopyPropertiesTo(result.getExchangeExtension());
// copy over state
result.setRouteStop(source.isRouteStop());
@@ -391,6 +393,7 @@ public final class ExchangeHelper {
result.getExchangeExtension().setNotifyEvent(source.getExchangeExtension().isNotifyEvent());
result.getExchangeExtension().setRedeliveryExhausted(source.getExchangeExtension().isRedeliveryExhausted());
result.getExchangeExtension().setErrorHandlerHandled(source.getExchangeExtension().getErrorHandlerHandled());
+
result.setException(source.getException());
}
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ExtendedExchangeExtension.java b/core/camel-support/src/main/java/org/apache/camel/support/ExtendedExchangeExtension.java
index f1f13fb139a..2ce20cdea33 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/ExtendedExchangeExtension.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/ExtendedExchangeExtension.java
@@ -288,6 +288,13 @@ public class ExtendedExchangeExtension implements ExchangeExtension {
return this.exchange.getSafeCopyProperty(key, type);
}
+ public void copySafeCopyPropertiesTo(ExchangeExtension target) {
+ if (exchange.safeCopyProperties != null && !exchange.safeCopyProperties.isEmpty()) {
+ exchange.safeCopyProperties.entrySet().stream()
+ .forEach(entry -> target.setSafeCopyProperty(entry.getKey(), entry.getValue().safeCopy()));
+ }
+ }
+
@Override
public boolean isFailureHandled() {
return this.failureHandled;