gnodet opened a new pull request, #31162:
URL: https://github.com/apache/camel/pull/31162

   ## Summary
   
   Fix `BackOffTimerTask` silently aborting route restart retries when a 
`java.lang.Error`
   (rather than an `Exception`) is thrown during a supervising route controller 
restart attempt.
   
   ## Root Cause
   
   `BackOffTimerTask.run()` had `catch (Exception e)` around the scheduled 
function call.
   A `java.lang.Error` thrown inside `function.apply(this)` escaped the catch 
block entirely.
   The `ScheduledExecutorService` then silently swallowed the escaping `Error` 
(per JDK contract:
   uncaught exceptions in scheduled tasks cancel the task without rescheduling 
it).
   Result: the task was never rescheduled, never marked `Failed`, and no log 
line was emitted —
   the route stayed `Stopped` with no explanation.
   
   `DefaultSupervisingRouteController`'s restart lambda had the same gap: its 
`catch (Exception e)`
   at line 766 also missed `Error`s thrown by `doStartRoute()`.
   
   ## Fix
   
   - **`BackOffTimerTask.run()`**: widen the catch to `Throwable` so any 
`Error` is captured,
     the task is marked `Failed`, and `whenComplete` callbacks are invoked.
     Additionally, the `complete()` call is moved outside the `try-catch` so 
errors thrown
     by `whenComplete` consumers are not incorrectly attributed to the function.
   
   - **`DefaultSupervisingRouteController`** restart lambda: widen `catch 
(Exception e)` to
     `catch (Throwable e)` so `Error`s from `doStartRoute()` are logged and 
back-off retries continue.
   
   ## Tests
   
   Added `testErrorThrownByFunctionTransitionsToFailed` to 
`SimpleBackOffTimerTest`:
   - Schedules a `BackOffTimerTask` whose function always throws 
`AssertionError`
   - Verifies the task reaches `Status.Failed` (not stuck in `Active`)
   - Verifies the `whenComplete` callback is invoked with the `AssertionError` 
as the cause
   - Test was **RED** before the fix and **GREEN** after
   
   Fixes CAMEL-27472
   
   ---
   _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]

Reply via email to