John Yin created CAMEL-20999:
--------------------------------
Summary: OnException - Handler is invoked twice per exception when
handled(false) is used
Key: CAMEL-20999
URL: https://issues.apache.org/jira/browse/CAMEL-20999
Project: Camel
Issue Type: Bug
Components: came-core
Affects Versions: 4.4.2
Environment: Camel 4.4.2 with SpringBoot 3.2.7 and JDK 17 on Windows.
Reporter: John Yin
Run the following route, the onException handler would be executed twice. The
counter will be 2.
{quote}int counter = 0
from("timer://testRoute2?repeatCount=1").routeId('testRoute_timer2').autoStartup(true)
.onException(IllegalArgumentException).onWhen(\{it.getException().toString().contains('foo')})
.process({
counter++
println "print in onException foo $counter"
}).handled(false)
.end()
.log('in testRoute2')
.process({
println 'before throwing exception'
throw new IllegalArgumentException("foo")
}){quote}
This would generate the following:
{quote}2024-07-19 17:46:11.711 [Camel (camel-1) thread #31 -
timer://testRoute2] testRoute_timer2 - in testRoute2
before throwing exception
print in onException foo 1
print in onException foo 2{quote}
If the handled(true) is used, the handler would only run once.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)