davsclaus opened a new pull request, #31337:
URL: https://github.com/apache/camel/pull/31337
## What was wrong
1. `InterceptReifier` removed its `InterceptDefinition` from the route
outputs when the route was created. Every path
that creates the route again from the same `RouteDefinition` lost the
intercept: `CamelContext` `stop()` + `start()`
(also for an intercept of a route configuration), `removeRouteDefinition`
+ `addRouteDefinition` of the same
definition, and `AdviceWith` after the context started (for a
RouteBuilder-level intercept).
2. The `first` flag in `ProcessorReifier` was `route.getOutputs().get(0) ==
definition`. When the route starts with a
merged onException, interceptSendToEndpoint, onCompletion or
interceptFrom, the first step the route author wrote
was not "first", so the BacklogDebugger `_all_routes_` initial breakpoint
was missing or on the wrong node.
3. Which steps an intercept intercepted depended on the build order of the
route: the steps of onException,
interceptFrom and interceptSendToEndpoint were not intercepted, but the
`onCompletion` step and the steps inside
`onCompletion` were.
## What changed
- `InterceptReifier` keeps its definition in the route and returns no
processor, as `InterceptSendToEndpointReifier`
does since CAMEL-25140. The intercept strategy is now a named class
(`InterceptDefinitionStrategy`) and no longer
keeps the last wrapped target in a shared field.
- `ProcessorReifier.wrapChannel`:
- an intercept is for the main route path: for a node that is (or is
inside) an onException, onCompletion,
interceptFrom or interceptSendToEndpoint, the intercept strategies of
`intercept` definitions are left out. This
does not depend on the build order any more. User-provided
`InterceptStrategy` instances (context, route, node)
are applied as before.
- the `first` flag is the first route output that is not an onException,
onCompletion, intercept, interceptFrom or
interceptSendToEndpoint.
- `RouteDefinitionHelper`: the same `InterceptDefinition` instance is
applied once. Now that the intercept stays in the
outputs, `AdviceWith` (which prepares the route again) would otherwise
apply the intercept of a route configuration
twice (once from the outputs, once from the configuration merged again).
CAMEL-28099 fixes the double merge in
general.
- `LwModelToYAMLDumper` also collects the context-scoped intercepts from the
route outputs (by `routeScoped=false`),
like interceptFrom and interceptSendToEndpoint, so they are not dumped
inline after `AdviceWith` reset the list
kept on the route.
- Docs: `intercept.adoc` says which steps are intercepted (the main route
path) and which are not.
Behaviour that is pinned but not changed: several intercepts of a
RouteBuilder run in declaration order; those of a
route configuration run in reverse declaration order, before those of the
RouteBuilder; an intercept also intercepts
the output steps of the intercepts created after it.
## Tests
- `InterceptMainPathTest` (new): route steps are intercepted; onException,
interceptFrom, interceptSendToEndpoint and
onCompletion (global, route scoped, route configuration) steps are not;
the order of several intercepts (RouteBuilder
and route configuration).
- `InterceptRouteLifecycleTest` (new): route stop/start, `CamelContext`
restart (RouteBuilder and route configuration
intercept), remove and add the same route definition, `AdviceWith` after
start (RouteBuilder and route
configuration intercept). All but stop/start failed before the fix.
- `ProcessorReifierFirstStepTest` (new): the `_all_routes_` initial
breakpoint is on the first step the author wrote
with onException, onCompletion, intercept, interceptFrom,
interceptSendToEndpoint. Failed before for all but
intercept.
- Updated counts: `OnCompletionAndInterceptTest`,
`OnCompletionAndInterceptGlobalTest`,
`OnCompletionAndInterceptAndOnExceptionGlobalTest` (5/4 intercepted steps
become 2/1), also used by the
`SpringOnCompletionAndIntercept*Test` copies in camel-spring-xml.
Ran: camel-core `*Intercept*`, `*OnCompletion*`, `*AdviceWith*`,
`*Debugger*`, `*RouteConfiguration*`, `*Dump*`;
camel-spring-xml `*Intercept*`, `*OnCompletion*`; camel-yaml-io (all),
camel-yaml-dsl `*Intercept*`, `*RouteConfiguration*`, `*Dump*`,
`*ContextScoped*`, `*OnCompletion*`; camel-xml-io-dsl same patterns;
camel-management `*Intercept*`, `*Debugger*`, `*OnCompletion*`; camel-java-io
(all). All green.
## Upgrade guide
Yes, 4.25: intercept no longer intercepts the steps of onCompletion, and the
intercept is kept when a route is created
again.
Fixes https://issues.apache.org/jira/browse/CAMEL-28100
_Claude Code on behalf of davsclaus_
🤖 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]