gnodet commented on PR #31136:
URL: https://github.com/apache/camel/pull/31136#issuecomment-7287601365

   Your analysis of `SedaConsumer` on current `main` is correct: the outer 
`catch (Throwable)` in `doRun()` already catches any `Error` (including 
`AssertionError`) that escapes the inner `catch (Exception)` around 
`processPolledExchange`. `testConsumerSurvivesNonFatalError` would indeed pass 
today without the production change.
   
   The fix as written is a **defensive refactor** for `SedaConsumer` — it 
handles errors at the right scope and makes the intent explicit. That is still 
reasonable, but the PR description ("escaped both catch blocks ... terminated 
the consumer thread permanently") is describing pre-CAMEL-27515 behaviour, not 
the current state.
   
   Where the gap is real, however, is in 
`ThreadPerTaskSedaConsumer.dispatch()`. Its lambda dispatches to a worker 
thread and only has `catch (Exception e)` — not `catch (Error)`:
   
   ```java
   taskExecutor.execute(() -> {
       try {
           // ...
           sendToConsumers(prepared, callback);
       } catch (Exception e) {  // Error not caught here
           getExceptionHandler().handleException(...);
       } finally {
           activeTasks.decrement();
           // ...
       }
   });
   ```
   
   An `Error` thrown from `sendToConsumers` on that worker thread escapes the 
lambda entirely, kills the worker thread, and leaks the `Semaphore` permit if 
`concurrencyLimiter != null` — the `finally` block runs `release()`, but 
`activeTasks.decrement()` still runs, so the count stays consistent. The actual 
risk is that the uncaught `Error` goes to the thread\u2019s uncaught exception 
handler and the task just disappears silently. The coordinator\u2019s outer 
`catch (Throwable)` in `doRun` never sees it because it lives in a different 
thread.
   
   Would it make sense to:
   1. Update the description to reflect that this is a defensive fix that also 
closes a real gap in `ThreadPerTaskSedaConsumer`, and
   2. Add a `catch (Error)` to `ThreadPerTaskSedaConsumer.dispatch()`\u2019s 
lambda (re-throw `VirtualMachineError`, pass others to the exception handler), 
symmetrically with what this PR does for `SedaConsumer`?
   
   That would give the PR a concrete, verifiable fix to point to, and the test 
could be adapted to cover the `ThreadPerTaskSedaConsumer` path where the gap is 
real today.
   
   _Hermès on behalf of gnodet_


-- 
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