Croway opened a new pull request, #23090:
URL: https://github.com/apache/camel/pull/23090
## Summary
- Fix `RedeliveryErrorHandler.incrementRedeliveryCounter()` to use the
internal `redeliveryCounter` field as the authoritative counter instead of
reading from the `CamelRedeliveryCounter` exchange header, which user routes
can remove (e.g., via `removeHeaders("*")`)
- Fix `prepareExchangeForRedelivery()` to restore redelivery headers from
internal state rather than saving/restoring from exchange headers — resolves a
[longstanding
TODO](https://github.com/apache/camel/blob/557b15f88e63cb9dfc8804eac7fbb8e5302b5e07/core/camel-core-processor/src/main/java/org/apache/camel/processor/errorhandler/RedeliveryErrorHandler.java#L1280-L1281)
present since Camel 2.8
- Add regression test (`RedeliverToSubRouteRemoveHeadersTest`) with two test
methods: one verifying the infinite loop is fixed, one verifying `onRedelivery`
processors see the correct counter
**Scenario:** parent route with `onException`/`maximumRedeliveries(3)` calls
a child route (via `direct:`) that uses `NoErrorHandler` and
`removeHeaders("*")`. The `removeHeaders` wipes `CamelRedeliveryCounter` during
each attempt. Before this fix, the counter reset to 1 every time, causing an
infinite redelivery loop.
The defensive-copy mechanism (`copyFrom(original)`) was introduced in Camel
2.8.0, but `incrementRedeliveryCounter()` was never updated to use the internal
field — it kept reading from the header as it had since before the defensive
copy existed. In Camel 2.7, `prepareExchangeForRedelivery()` did not copy from
the original, so headers survived intact and this bug did not manifest.
## Test plan
- [x] New test
`RedeliverToSubRouteRemoveHeadersTest.testRedeliveryCounterWithRemoveHeaders` —
verifies redelivery exhausts correctly (no infinite loop)
- [x] New test
`RedeliverToSubRouteRemoveHeadersTest.testOnRedeliverySeesCorrectCounter` —
verifies `onRedelivery` processor sees counters `[1, 2, 3]`
- [x] Existing `RedeliverToSubRouteTest` passes (no regression)
- [x] Existing `DeadLetterChannelOnExceptionOnRedeliveryTest` passes (no
regression)
- [x] Existing `DefaultErrorHandlerRedeliveryTest`,
`RedeliveryErrorHandlerLogHandledTest`, `DeadLetterChannelRedeliveryTest`,
`DeadLetterChannelOnRedeliveryTest`,
`ErrorHandlerOnExceptionRedeliveryAndHandledTest` all pass (16 tests total, no
regressions)
--
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]