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

   ## Summary
   
   Add an inner `catch (Error)` guard around `processPolledExchange` in 
`SedaConsumer.doRun()` so that non-fatal JVM errors thrown by route code (e.g. 
`AssertionError`) are handled by the exception handler and do not kill the 
consumer thread.
   
   ## Root Cause
   
   `SedaConsumer.doRun()` only had `catch (Exception)` around the call to 
`processPolledExchange`. Any `Error` thrown by route code escaped both catch 
blocks, propagated up through `run()`, and terminated the consumer thread 
permanently. The SEDA queue kept accumulating messages while the route appeared 
`Started`, with no consumer draining it.
   
   ## Fix
   
   Adds `catch (Error e)` immediately after `catch (Exception e)` in the inner 
try-block around `processPolledExchange`:
   
   - If the caught `Error` is a `VirtualMachineError`, it is re-thrown so that 
the outer `catch (VirtualMachineError)` (added by CAMEL-27515) can call 
`handleFatalError` and stop the consumer cleanly — a restart of the route is 
then required.
   - For any other `Error` (e.g. `AssertionError`, `LinkageError`), the 
exception is passed to the exception handler and the polling loop continues, 
keeping the consumer thread alive.
   
   The redundant outer `catch (Error)` block that was initially included is 
removed, as the existing `catch (Throwable)` already covers errors outside of 
`processPolledExchange`.
   
   ## Tests
   
   `SedaConsumerVirtualMachineErrorTest` overrides `processPolledExchange` to 
throw `AssertionError` on the first exchange. It verifies that the consumer 
thread continues polling and drains all remaining exchanges from the queue 
after the error.
   
   Fixes CAMEL-27471
   
   ---
   _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