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:49:32 UTC

[camel] branch camel-3.21.x 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 camel-3.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.21.x by this push:
     new 7c1e8b76710 CAMEL-19670: camel-core - UnitOfWork should not use stream caching in useOriginalMessage if not enabled. (#10925)
7c1e8b76710 is described below

commit 7c1e8b76710cd7c86e3aeac1d4c669c3ffdee439
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 39971ace493..e82e4e85bb8 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
@@ -35,6 +35,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;
@@ -53,6 +54,7 @@ public class DefaultUnitOfWork implements UnitOfWork {
 
     // instances used by MDCUnitOfWork
     final InflightRepository inflightRepository;
+    final StreamCachingStrategy streamCachingStrategy;
     final boolean allowUseOriginalMessage;
     final boolean useBreadcrumb;
 
@@ -82,6 +84,7 @@ public class DefaultUnitOfWork implements UnitOfWork {
         this.useBreadcrumb = useBreadcrumb;
         this.context = (ExtendedCamelContext) exchange.getContext();
         this.inflightRepository = inflightRepository;
+        this.streamCachingStrategy = exchange.getContext().getStreamCachingStrategy();
         doOnPrepare(exchange);
     }
 
@@ -116,10 +119,12 @@ public class DefaultUnitOfWork implements UnitOfWork {
             if (this.originalInMessage instanceof MessageSupport) {
                 ((MessageSupport) this.originalInMessage).setExchange(exchange);
             }
-            // 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 = context.getStreamCachingStrategy().cache(this.originalInMessage);
+                if (cache != null) {
+                    this.originalInMessage.setBody(cache);
+                }
             }
         }