davsclaus opened a new pull request, #26929: URL: https://github.com/apache/camel/pull/26929
Fixes [CAMEL-25048](https://issues.apache.org/jira/browse/CAMEL-25048): bugs in route templates found in a deep review. Each fix has a test in `RouteTemplateEdgeCasesTest` that fails without it. 1. **A local bean referred to by a parameter is only renamed for one of the parameter's keys.** Every parameter is stored as both camelCase and kebab-case (`beanRef` and `bean-ref`). When its value names a local bean (which is renamed to be unique), only the first key was renamed and the bean was then removed from the list, so the other key kept the old name. Depending on HashMap order, `to("bean:{{beanRef}}")` failed with `NoSuchBeanException`. All local beans are now renamed in one pass and every parameter referring to one is updated. 2. **The destroy method of such a local bean is never called**, as the renaming removed it from the local bean repository that is closed when the route is removed. 3. **A local bean from a supplier is not a singleton.** `templateBean(name, type, rtc -> ...)` and a templated route `bean(...)` with a supplier called it on every lookup. They are now cached (as `SupplierRegistry` documents); `bindAsPrototype`, which failed with `UnsupportedOperationException`, binds without caching. 4. **`TemplatedRouteDefinition.bean(name, language, script)` sets the language as the type** and fails with `ClassNotFoundException`. 5. **A local bean factory does not see a parameter given in the other key style or from an environment variable** (`rtc.getProperty("myRegion")` with `my-region=eu` was null), while the route used the given value. 6. **The configurer of `TemplatedRouteBuilder` is dropped when the template also has one.** Both are now called, the template first. 7. **Node ids of a route from a template are compared unprefixed with other routes.** A hardcoded node id in a template clashed with the same id in a regular route (a false duplicate id, depending on the order routes are added), while two template routes with the same `prefixId` were not reported although their ids are the same at runtime. `route-template.adoc` said routes from the same template give duplicate ids, which has not been the case since CAMEL-21475. 8. **A `#class` local bean is bound as `Object`**, so it cannot be looked up by type. It is now bound with its class (not when a factory method creates it). **Not changed** - A bean given to `TemplatedRouteBuilder` with the same name as a `templateBean` is overridden by the template bean; the precedence needs a decision. - A route id from a template that is the same as an existing route replaces that route, as adding a route with an existing id does. 6 and 7 change behaviour and are in the 4.23 upgrade guide. The whole `camel-core` test suite passes (one timing test passed on rerun), and so do the `camel-kamelet` and `camel-yaml-dsl` tests. _Claude Code on behalf of Claus Ibsen_ 🤖 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]
