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

Guillaume Nodet commented on CAMEL-27470:
-----------------------------------------

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

Code analysis confirms two issues: (1) TimerConsumer.TimerTask.run() catches 
only Exception - per JDK java.util.Timer contract, any unchecked Throwable from 
run() terminates the Timer thread and kills ALL tasks sharing that timer name 
(TimerComponent shares one Timer per timer name); (2) the negative-delay 
executor path has no try/catch at all around sendTimerExchange(). Fix: widen 
catch to Throwable (re-throwing VirtualMachineError as cancel-and-rethrow) so 
the shared Timer thread survives.

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

> camel-timer - a VirtualMachineError in a timer route stops every timer route 
> with the same timer name
> -----------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-27470
>                 URL: https://issues.apache.org/jira/browse/CAMEL-27470
>             Project: Camel
>          Issue Type: Sub-task
>          Components: camel-core
>            Reporter: Federico Mariani
>            Assignee: Guillaume Nodet
>            Priority: Major
>
> {{TimerConsumer}} sends the exchanges from a {{java.util.TimerTask}} whose 
> {{run()}} catches only {{Exception}}. A {{VirtualMachineError}} thrown in the 
> route, which CAMEL-26741 throws on to the caller on purpose (such as a 
> {{StackOverflowError}} of a recursive call), ends the thread of the 
> {{java.util.Timer}}, and the Timer then cancels all its tasks. Every timer 
> route that uses the same timer (the same {{timerName}}, by default the name 
> in the URI) stops firing, and the routes still say Started. Only the default 
> handler of the JVM prints the Error, on stderr.
> Reproduced on main, with two routes from {{timer:shared?period=50}}, the 
> first of which throws a {{StackOverflowError}} on its third exchange:
> {noformat}
> route a: 3 exchanges, then none in the next 2 seconds, status Started
> route b: 2 exchanges, then none in the next 2 seconds, status Started
> {noformat}
> With a negative {{delay}}, the loop on the executor has no catch either 
> (found by reading the code, not reproduced).
> Suggested fix: catch the Error in {{run()}} and log it at ERROR. A 
> {{VirtualMachineError}} may at most cancel the task of this route 
> ({{TimerTask.cancel()}}), so that it does not end the Timer that other routes 
> share.
> _Claude Code on behalf of Croway_



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

Reply via email to