Federico Mariani created CAMEL-26980:
----------------------------------------

             Summary: camel-core: throwException with an exception instance 
gets a suppressed exception added for every failed message
                 Key: CAMEL-26980
                 URL: https://issues.apache.org/jira/browse/CAMEL-26980
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 4.18.5, 4.23.0, 4.22.2
            Reporter: Federico Mariani
             Fix For: 4.24.0


A throwException step given an exception instance (Java DSL 
{{throwException(new X(..))}}, or a bean by {{ref}}) sets that one object on 
every message. The error handlers (FatalFallbackErrorHandler, 
RedeliveryErrorHandler) then add the previous exception of each message to it 
as suppressed, so the shared instance keeps the exceptions of all the messages 
and grows with each failure for the lifetime of the route.

{code:java}
IllegalStateException translated = new IllegalStateException("Translated");
from("direct:start")
    .onException(IOException.class).throwException(translated).end()
    .throwException(IOException.class, "Failure of ${exchangeId}");
// after N messages: translated.getSuppressed().length == N
{code}
The same happens with doTry/doCatch followed by throwException(instance).

Expected: Camel does not change the configured instance. throwException(type, 
message) keeps creating a new exception per message, with the previous one as 
suppressed.

_Claude Code on behalf of Federico Mariani_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to