This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-3.11.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-3.11.x by this push: new a761011 CAMEL-16990: camel-core - Stream caching checking for caused exception can lead to converter problem a761011 is described below commit a761011f3d390631f540d8297d906b4888994366 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 8cf3552..83e010f 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);