gnodet opened a new pull request, #30713:
URL: https://github.com/apache/camel/pull/30713
## Summary
`TimerConsumer.TimerTask.run()` caught only `Exception`. The CAMEL-26741 fix
causes `DelegateSyncProcessor` and `CamelInternalProcessor` to re-throw
`VirtualMachineError` (e.g. `StackOverflowError`) to the caller. When the
caller is the `run()` of a `TimerTask` on the shared `java.util.Timer`
thread,
the JDK `Timer` contract states that any unchecked `Throwable` from `run()`
terminates the timer thread and silently cancels **all** tasks sharing that
timer name — stopping every route with the same `timerName`, with no visible
error (routes still report `Started`).
The executor path (negative `delay`) had no `catch` at all.
## Root Cause
`java.util.Timer.mainLoop()` does not catch `Throwable`: any error escaping
`TimerTask.run()` kills the shared timer thread and all its tasks.
Before CAMEL-26741 this was masked because Camel's error handling caught
`Throwable` and stored it on the exchange. CAMEL-26741 intentionally
re-throws `VirtualMachineError` through the pipeline, exposing the timer bug.
## Fix
**`TimerTask.run()`** — add `catch (Throwable t)` after `catch (Exception
e)`:
- Call `cancel()` on the failing `TimerTask` (cancels this route only; the
shared `Timer` thread keeps running for all other routes).
- Log at `ERROR`.
- Do **not** re-throw: any re-throw from `run()` would still kill the shared
`Timer` thread, defeating the fix.
**Executor path** (`delay < 0`) — add `catch (Throwable t)` around the loop:
- Log at `ERROR` (no shared `Timer` to protect, but the error must not go
unnoticed).
## Tests
`TimerVirtualMachineErrorTest` (in `core/camel-core`):
- Two routes share `timer:shared?period=50&synchronous=true`.
- Route A throws `StackOverflowError` on its third exchange.
- Route B must keep firing after route A's error.
- **RED on unfixed code** (3/3 runs: timer thread dies, route B stops).
- **GREEN with fix** (passes in ~3 s).
- All 33 existing timer tests pass.
Fixes https://issues.apache.org/jira/browse/CAMEL-27470
---
_Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]