shashank created CAMEL-24925:
--------------------------------
Summary: 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
{{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)