davsclaus opened a new pull request, #31335:
URL: https://github.com/apache/camel/pull/31335
## What was wrong
`DefaultCamelContext.startRouteDefinitions` prepares a route that is not
prepared yet with
`RouteDefinitionHelper.prepareRoute(ctx, def)`, which does not merge the
route configurations; only
`RoutesDefinition.prepareRoute` does (used by `RouteBuilder` and
`DefaultModel.addRouteFromTemplate`).
So a route added with `ModelCamelContext.addRouteDefinition(s)` as an
unprepared `RouteDefinition` started without any
route configuration, global or named. This includes JMX
`ManagedRoute.updateRouteFromXml`: the replacement route lost
the global `onException` the original route had.
## What changed
- `DefaultCamelContext.startRouteDefinitions` prepares such a route with a
`RoutesDefinition` bound to the
`CamelContext` (keeping the route's resource), the same way as
`DefaultModel.addRouteFromTemplate`.
- Routes that are prepared already (`RouteBuilder`, YAML/XML DSL, rest DSL,
templates, Kamelets, Spring XML) are skipped
by the existing `isPrepared()` check, so nothing is merged twice.
- Error handler precedence is the one of `RouteBuilder` routes: the route's
own error handler, then the one of the route
configuration, then the context default.
- `routeConfigurationId` is resolved as for a `RouteBuilder` route
(placeholders with template parameters; the local
properties of the properties component are a stack, so the template
parameters set by `startRouteDefinitions` stay).
## Tests
- `RoutesConfigurationAddRouteDefinitionTest` (camel-core): global and named
`onException`, configuration error
handler, route's own error handler wins, re-adding a prepared route does
not merge again. 3 of 5 fail before the fix.
- `ManagedRouteUpdateRouteFromXmlRouteConfigurationTest` (camel-management):
`updateRouteFromXml` keeps the global
`onException`, and a `routeConfigurationId` in the XML selects the named
one. Both fail before the fix.
- Ran: camel-core `RoutesConfiguration*`, `RouteConfiguration*`,
`RouteTemplate*`, `*AdviceWith*`, `*Inline*`,
`*AddRoute*`, `*RemoveRoute*`, `*RouteChecksum*`, `*TemplatedRoute*`,
`*ErrorHandler*`, `org.apache.camel.model.**`,
rest, Kamelet and reload tests, and the tests that call
`addRouteDefinition`; camel-management `ManagedRouteUpdate*`
and `*FromXml*`; camel-spring-xml route configuration tests; camel-kamelet
route configuration and error handler
tests. All green.
## Upgrade guide
Entry added to the 4.25 upgrade guide: routes added this way now get the
matching route configurations.
Fixes https://issues.apache.org/jira/browse/CAMEL-28097
_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]