davsclaus opened a new pull request, #26811: URL: https://github.com/apache/camel/pull/26811
_Claude Code on behalf of Claus Ibsen (davsclaus)_ JIRA: https://issues.apache.org/jira/browse/CAMEL-24978 A deep review of the routing engine's internal processor (`CamelInternalProcessor`, `SharedCamelInternalProcessor`, `AdviceIterator` and the built-in advices) found the bugs below. Each fix has a test that fails without it. The normal path, where each `before` is followed by its `after`, is sound. All the bugs are on edge paths. 1. **After advices were not run on the debugger's skip over, or when an advice failed in `before`.** - **Skip over:** all the `before` advices had run, but the skip-over branch only called the callback. The JMX inflight counter of the skipped processor never went down, and the message history entry was left unfinished. With tracing on, the exchange also stayed in the tracer's event notifier map. - **Failing `before`:** the advices that had already run were never undone. The route's inflight count stayed up, the route stack was not popped, and a unit of work created by the route was not done. - Both paths now run `after` for exactly the advices whose `before` ran, each with its own state. - An exception thrown from an `after` advice no longer replaces the exception the exchange already failed with. It is added as a suppressed exception instead. 2. **rest-openapi and rest-postman ran each operation twice after a route restart.** The consumer is created again when a route is restarted, and each time another processor advice was added without removing the previous one. So each restart added one more invocation per request. The advice from the previous start is now removed first. 3. **Backlog tracer advice fixes:** - the aggregate advice now checks `shouldTrace`. Before, in standby mode every aggregated exchange was dumped and traced even when tracing was off. - the endpoint service details are now set on the *last* trace event; before, they were set on the first. - an unused private method is removed. - `addRouteInflightRepositoryAdvice` now uses its inflight repository parameter. 4. **Upgrade guide entry** (4.23) for the changed behavior in item 1. ### Not changed (left for follow-up) - **Aggregate trace levels:** the aggregate's first trace event uses `level + 1`, and its last uses `1`. It is unclear what the CLI history expects, so this is left as is. - **Pooled task states:** pooled after-tasks keep a `states` array sized when the task was created. Adding a stateful advice at runtime with the pooled exchange factory, or a processor calling `done` twice, could misalign states. This path is opt-in. - **`SharedCamelInternalProcessor`** still calls `uow.afterProcess` in the current thread, on top of the callback-based call from CAMEL-18255, so the MDC is cleared twice. This is harmless but inconsistent. ### Tests - New tests: - `CamelInternalProcessorAdviceTest` (camel-core); - `ManagedProcessorSkipOverTest` and `BacklogTracerAggregateStandbyTest` (camel-management); - route-restart tests in `PlatformHttpRestOpenApiConsumerTest` and `PlatformHttpRestPostmanConsumerTest`. - Full camel-core suite: 7,496 tests pass. One flaky interrupt during shutdown in `AggregateForceCompletionOnStopParallelTest` passed on rerun, and then 5 more times out of 5. - Full camel-management suite: 478 tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
