[ 
https://issues.apache.org/jira/browse/CAMEL-27472?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18153246#comment-18153246
 ] 

Guillaume Nodet commented on CAMEL-27472:
-----------------------------------------

This issue is being investigated by a coding agent (on behalf of gnodet).

Root cause confirmed in BackOffTimerTask.java (core/camel-util). The run() 
method at line 201 catches only Exception. When the restart lambda 
(DefaultSupervisingRouteController line 736-774) throws an Error (e.g. 
ExceptionInInitializerError, NoClassDefFoundError) from doStartRoute(), it 
escapes the lambda catch(Exception) at line 766, then also escapes 
BackOffTimerTask.run() catch(Exception) at line 201. The 
ScheduledExecutorService logs it to stderr but the task is never rescheduled. 
No more restart attempts are made, the route stays Stopped, and no Camel event 
or log line is produced.

Fix: in BackOffTimerTask.run(), widen the catch to Throwable (rethrow 
VirtualMachineError, set status=Failed and log for other Errors). 
Alternatively, in the DefaultSupervisingRouteController restart lambda, catch 
Throwable and rethrow after logging.

_Note: This comment was generated by an AI coding agent and requires manual 
verification._

> camel-core - Supervising route controller: an Error in a restart attempt ends 
> the restarts of the route, without a log line
> ---------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27472
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27472
>             Project: Camel
>          Issue Type: Sub-task
>          Components: camel-core
>            Reporter: Federico Mariani
>            Assignee: Guillaume Nodet
>            Priority: Major
>
> {{BackOffTimerTask.run()}} (camel-util) catches only {{Exception}}, and so 
> does the restart function of {{DefaultSupervisingRouteController}}. An Error 
> in a restart attempt, such as an {{ExceptionInInitializerError}} or a 
> {{NoClassDefFoundError}} when the consumer starts and loads a class of its 
> client for the first time, escapes the task, and the scheduler keeps it in a 
> {{Future}} that nothing reads. No more attempts are made, and the task does 
> not complete: the route is neither started nor marked exhausted, no restart 
> failure event is sent, and nothing is logged. The route stays Stopped.
> Reproduced on main, with {{backOffDelay=100}} and a consumer whose first 
> start throws an {{IllegalStateException}}, the second an 
> {{ExceptionInInitializerError}}, and the third would succeed:
> {noformat}
> after 3 seconds: 2 starts, route Stopped, getRestartingRoutes()=[flaky], 
> getExhaustedRoutes()=[]
> log: "Restarting route: flaky attempt: 1", and nothing after it
> {noformat}
> Found by reading the code, not reproduced: the first start of the supervised 
> routes ({{doStartSupervisedRoutes}}) also catches only {{Exception}} around 
> each route, so an Error there skips the routes after it.
> Suggested fix: in {{BackOffTimerTask.run()}}, catch {{Throwable}}, mark the 
> task Failed and complete it with the Error. In the restart function, handle 
> an Error that is not a {{VirtualMachineError}} as a failed attempt.
> _Claude Code on behalf of Croway_



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

Reply via email to