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 264ab77  CAMEL-16990: camel-core - Stream caching checking for caused 
exception can lead to converter problem
264ab77 is described below

commit 264ab77dc2d4c46c6d9d07f67e2986eef7c829b5
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Tue Sep 21 15:33:55 2021 +0200

    CAMEL-16990: camel-core - Stream caching checking for caused exception can 
lead to converter problem
---
 .../org/apache/camel/impl/engine/CamelInternalProcessor.java  | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
index 741b657..b638ca5 100644
--- 
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
+++ 
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
@@ -65,6 +65,7 @@ import org.apache.camel.support.SynchronizationAdapter;
 import org.apache.camel.support.UnitOfWorkHelper;
 import org.apache.camel.support.processor.DelegateAsyncProcessor;
 import org.apache.camel.support.service.ServiceHelper;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.StopWatch;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -914,11 +915,15 @@ public class CamelInternalProcessor extends 
DelegateAsyncProcessor implements In
                 sc.reset();
                 return sc;
             }
-            // cache the body and if we could do that replace it as the new 
body
-            boolean failed = exchange.getException(StreamCacheException.class) 
!= null
-                    || 
exchange.getProperty(ExchangePropertyKey.EXCEPTION_CAUGHT, 
StreamCacheException.class) != null;
+            // check if we somewhere failed due to a stream caching exception
+            Throwable cause = exchange.getException();
+            if (cause == null) {
+                cause = 
exchange.getProperty(ExchangePropertyKey.EXCEPTION_CAUGHT, Throwable.class);
+            }
+            boolean failed = cause != null && 
ObjectHelper.getException(StreamCacheException.class, cause) != null;
             if (!failed) {
                 try {
+                    // cache the body and if we could do that replace it as 
the new body
                     StreamCache sc = strategy.cache(exchange);
                     if (sc != null) {
                         exchange.getIn().setBody(sc);

Reply via email to