gnodet opened a new pull request, #21219:
URL: https://github.com/apache/camel/pull/21219
## Description
Fixes CAMEL-22907: Consumer errors with `bridgeErrorHandler=true` and
`handled(false)` now properly execute onException routes.
## Problem
When a consumer error occurred with `bridgeErrorHandler=true` and the error
handler had `handled(false)`, the onException route was not being executed. The
exchange would stop at the error handler instead of continuing to configured
subroutes.
## Root Cause
The `SimpleTask.handlePreviousFailure()` method in `RedeliveryErrorHandler`
was taking a shortcut for bridged errors. It only called `handleException()`
and `onExceptionOccurred()`, but never invoked the actual failure processor
(the onException route body).
## Solution
Modified `SimpleTask.handlePreviousFailure()` to properly handle bridged
errors by:
- Retrieving the exception policy and failure processor
- Invoking a new `deliverToFailureProcessor()` method that mirrors the
`RedeliveryTask` implementation
- Properly handling both `handled(false)` and `continued(true)` scenarios
- Temporarily clearing the exception during route execution, then restoring
it afterwards for `handled(false)`
## Changes
### Modified Files
-
`core/camel-core-processor/src/main/java/org/apache/camel/processor/errorhandler/RedeliveryErrorHandler.java`
- Modified `SimpleTask.handlePreviousFailure()` method
- Added `deliverToFailureProcessor()` method
- Added helper methods: `shouldHandle()`, `shouldContinue()`,
`prepareExchangeAfterFailure()`, `prepareExchangeForContinue()`
- Added comprehensive JavaDoc documentation
### New Files
-
`core/camel-core/src/test/java/org/apache/camel/processor/DefaultConsumerBridgeErrorHandlerContinuedTest.java`
- New test for `continued(true)` scenario with `bridgeErrorHandler=true`
## Testing
✅ **All existing tests pass:**
- 11 BridgeErrorHandler tests - all pass
- 196 ErrorHandler tests - all pass
✅ **New test passes:**
- `DefaultConsumerBridgeErrorHandlerContinuedTest` - tests `continued(true)`
scenario
✅ **Verified with reproducer:**
- Tested with the reproducer from the JIRA issue
- Confirmed that the onException route executes correctly with
`handled(false)`
## Risk Assessment
**Risk: LOW**
- **Targeted scope**: Only affects the `SimpleTask.handlePreviousFailure()`
path for bridged errors
- **Proven pattern**: Mirrors the existing
`RedeliveryTask.deliverToFailureProcessor()` implementation
- **Comprehensive testing**: 207 existing tests pass without modification
- **Isolated impact**: Only affects consumers with `bridgeErrorHandler=true`
and `handled(false)`
## Documentation
Added comprehensive JavaDoc to all modified and new methods explaining:
- The purpose of each method
- How bridged errors are handled
- The behavior with `handled(false)` and `continued(true)`
- The exception clearing and restoration logic
---
Pull Request opened by [Augment Code](https://www.augmentcode.com/) with
guidance from the PR author
--
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]