You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2023/07/31 10:47:12 UTC
[camel] branch main updated: CAMEL-19670: camel-core - UnitOfWork should not use stream caching in useOriginalMessage if not enabled. (#10925)
This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 db806958b6e CAMEL-19670: camel-core - UnitOfWork should not use stream caching in useOriginalMessage if not enabled. (#10925)
db806958b6e is described below
commit db806958b6e30d3f9e7122bf14799340a23af414
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Jul 31 12:47:05 2023 +0200
CAMEL-19670: camel-core - UnitOfWork should not use stream caching in useOriginalMessage if not enabled. (#10925)
---
.../org/apache/camel/impl/engine/DefaultUnitOfWork.java | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java
index aa4e27cd806..002290086af 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultUnitOfWork.java
@@ -34,6 +34,7 @@ import org.apache.camel.Processor;
import org.apache.camel.Route;
import org.apache.camel.StreamCache;
import org.apache.camel.spi.InflightRepository;
+import org.apache.camel.spi.StreamCachingStrategy;
import org.apache.camel.spi.Synchronization;
import org.apache.camel.spi.SynchronizationVetoable;
import org.apache.camel.spi.UnitOfWork;
@@ -50,6 +51,7 @@ public class DefaultUnitOfWork implements UnitOfWork {
// instances used by MDCUnitOfWork
final InflightRepository inflightRepository;
+ final StreamCachingStrategy streamCachingStrategy;
final boolean allowUseOriginalMessage;
final boolean useBreadcrumb;
@@ -79,6 +81,7 @@ public class DefaultUnitOfWork implements UnitOfWork {
this.useBreadcrumb = useBreadcrumb;
this.context = exchange.getContext();
this.inflightRepository = inflightRepository;
+ this.streamCachingStrategy = exchange.getContext().getStreamCachingStrategy();
doOnPrepare(exchange);
}
@@ -102,10 +105,12 @@ public class DefaultUnitOfWork implements UnitOfWork {
if (allowUseOriginalMessage) {
this.originalInMessage = exchange.getIn().copy();
- // if the input body is streaming we need to cache it, so we can access the original input message
- StreamCache cache = context.getStreamCachingStrategy().cache(this.originalInMessage);
- if (cache != null) {
- this.originalInMessage.setBody(cache);
+ if (streamCachingStrategy.isEnabled()) {
+ // if the input body is streaming we need to cache it, so we can access the original input message
+ StreamCache cache = streamCachingStrategy.cache(this.originalInMessage);
+ if (cache != null) {
+ this.originalInMessage.setBody(cache);
+ }
}
}