You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2026/09/24 11:07:00 UTC
[jira] [Updated] (CAMEL-24981) camel-core - Error handler keeps the onException of an earlier redelivery attempt when the exception type changes
[ https://issues.apache.org/jira/browse/CAMEL-24981?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen updated CAMEL-24981:
--------------------------------
Fix Version/s: 4.23.0
> camel-core - Error handler keeps the onException of an earlier redelivery attempt when the exception type changes
> -----------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-24981
> URL: https://issues.apache.org/jira/browse/CAMEL-24981
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Reporter: Claus Ibsen
> Assignee: Claus Ibsen
> Priority: Minor
> Fix For: 4.23.0
>
>
> If the exception changes type between redelivery attempts, the error handler keeps using the onException settings chosen for the first exception.
> h3. Reproducer
> {code:java}
> errorHandler(deadLetterChannel("mock:dead"));
> onException(IOException.class).maximumRedeliveries(1).handled(true).to("mock:io");
> from("direct:b").process(e -> {
> if (attempt.getAndIncrement() == 0) {
> throw new IOException("first");
> }
> throw new IllegalArgumentException("second");
> });
> {code}
> The first attempt fails with IOException and is redelivered. The redelivery fails with IllegalArgumentException, which no onException matches, so it should go to the dead letter channel. Instead it is routed to mock:io and marked handled by the IOException onException.
> h3. Cause
> RedeliveryErrorHandler.RedeliveryTask.handleException only overwrites the failure processor, handled/continued/retryWhile predicates, useOriginalMessage/Body, onRedelivery/onExceptionOccurred processors and redelivery policy when an exception policy matches. It never resets them to the error handler defaults first, so values from an earlier attempt's policy carry over. The redelivery policy is also derived from the previous attempt's derived policy instead of the error handler's own policy. This behaviour dates from 2009, and nothing in history or JIRA says it was intended.
> h3. Fix
> Reset the per-attempt state to the error handler defaults before applying the policy that matches the current exception.
> _Claude Code on behalf of Claus Ibsen_
--
This message was sent by Atlassian Jira
(v8.20.10#820010)