[
https://issues.apache.org/jira/browse/CAMEL-24925?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-24925.
---------------------------------
Fix Version/s: 4.23.0
Resolution: Fixed
The fix is merged on main, so it is in Camel 4.23.0:
* f43584ac99c5 CAMEL-24925: camel-core - onException redeliveryDelay and
maximumRedeliveryDelay should accept durations such as 5s
Resolving, as the ticket was not updated when the PR was merged.
_Claude Code on behalf of Claus Ibsen_
> onException redeliveryDelay("5s") fails at runtime with "Error parsing [5s]
> as a java.lang.Long"
> ------------------------------------------------------------------------------------------------
>
> Key: CAMEL-24925
> URL: https://issues.apache.org/jira/browse/CAMEL-24925
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Reporter: shashank
> Priority: Minor
> Fix For: 4.23.0
>
>
> {{redeliveryDelay}} and {{maximumRedeliveryDelay}} are typed as
> {{java.time.Duration}} in {{RedeliveryPolicyDefinition}} and in the catalog,
> and on the error handler a value such as {{"500ms"}} or {{"1s"}} works. On
> {{onException}} it does not:
> {code:java}
> onException(IllegalStateException.class).maximumRedeliveries(2).redeliveryDelay("1s");
> from("direct:start").process(e -> { throw new IllegalStateException("boom");
> });
> {code}
> The route starts without an error. On the first failure the exchange fails at
> once with
> {{RuntimeCamelException: java.lang.IllegalArgumentException: Error parsing
> [1s] as a java.lang.Long.}}
> No redelivery happens, and the original {{IllegalStateException}} is replaced
> by the parse error. The same happens with {{maximumRedeliveryDelay("1m")}}
> and with {{<onException><redeliveryPolicy redeliveryDelay="5s"/>}} in XML or
> YAML. {{redeliveryDelay("500")}} works.
> For comparison,
> {{errorHandler(defaultErrorHandler().maximumRedeliveries(2).redeliveryDelay("1s"))}}
> redelivers twice with a 1 second delay.
> Cause: {{ExceptionPolicy.createRedeliveryPolicy}} parses both options with
> {{CamelContextHelper.parseLong}}, while
> {{ErrorHandlerReifier.createRedeliveryPolicy(RedeliveryPolicyDefinition,
> ...)}} uses {{CamelContextHelper.parseDuration}}. The deprecated
> {{ErrorHandlerReifier.createRedeliveryPolicy(Map, ...)}} has the same
> {{parseLong}} code.
> Proposed fix: use {{CamelContextHelper.parseDuration(...).toMillis()}} for
> both options in {{ExceptionPolicy}} (and in the deprecated method). Plain
> numbers keep meaning milliseconds.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)