davsclaus opened a new pull request, #31333:
URL: https://github.com/apache/camel/pull/31333
## What was wrong
`LwModelToYAMLDumper` pulls the context scoped definitions (onException,
intercept, interceptFrom,
interceptSendToEndpoint, onCompletion) out of the routes again (CAMEL-25490,
CAMEL-25494, CAMEL-25651). It decided by
object identity against the **current** route configurations whether a
definition belongs to a route configuration
(then it is dumped with the configuration) or is a top-level one.
`DefaultDumpRoutesStrategy.isInRouteConfiguration`
(the warning about the scope of a top-level onException) did the same.
When a route configuration is updated (removed and added again, as a route
reload does), the running routes still hold
the definitions of the old configuration, which is in no current
configuration. The dumper then wrote the old
onException as a top-level onException, which would apply to every route of
the file when the dump is loaded.
## What changed
* `RouteDefinitionHelper.getRouteConfigurationDefinitionConsumer` (the merge
of the route configurations into a route)
now links the onExceptions, intercepts, interceptFroms and
interceptSendTos of a route configuration to it with the
existing `routeConfiguration` back-pointer, when not set yet. The Java
fluent `RouteConfigurationDefinition` methods
already set it; the YAML and XML DSLs set the definitions as lists, so
they did not. This is the same as what
CAMEL-25420 does for onCompletion. The back-pointer has no runtime effect
for these definitions (only the fluent
builder and the onCompletion reifier read it).
* `LwModelToYAMLDumper` and `DefaultDumpRoutesStrategy` treat a definition
with that back-pointer as one of a route
configuration, and keep the identity check as a fallback. The five
identity helpers of the dumper are folded into one.
A definition of an old, replaced route configuration is **skipped** (not
dumped as top-level): the route configuration
is dumped with its current content, and the dumped route keeps its
`routeConfigurationId`, so loading the dump gives
the route the current configuration. The dump of a route therefore does not
change when its configuration is updated.
Dumps without an update are unchanged.
The route refresh of CAMEL-25142 would remove the cause (the routes would
hold the current definitions); this fix makes
the dumpers right independently of that.
## Tests
* New `DumpModelAsYamlRouteConfigurationUpdateTest` (camel-core): update a
route configuration built with the fluent
builder, and one built as lists (as the YAML/XML DSLs do, with an
onException and an interceptSendToEndpoint), then
dump the route as YAML: no top-level onException /
interceptSendToEndpoint, and the same dump as before the update.
A third test checks that a top-level onException of the RouteBuilder is
still dumped once. All three fail without the
fix.
* Ran: camel-core
`DumpModel*,*DumpRoutes*,*RouteConfiguration*,*RoutesConfiguration*,*OnCompletion*,*Intercept*,*OnException*`
(736 tests), camel-yaml-io (all, 193), camel-yaml-dsl
`*Dump*,RouteConfiguration*,OnException*,*Intercept*,*OnCompletion*`
(53), camel-xml-io-dsl `*RouteConfiguration*,*Dump*,*Routes*Loader*` (9):
all green.
No upgrade guide entry: only the dump after a route configuration update
changes, which was wrong.
Fixes https://issues.apache.org/jira/browse/CAMEL-28098
_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]