davsclaus opened a new pull request, #27536: URL: https://github.com/apache/camel/pull/27536
https://issues.apache.org/jira/browse/CAMEL-25428 In dev mode (`camel run --dev`), changing the Java class of a bean declared in a beans file (such as `beans.yaml`) recompiled the class and reloaded the routes, but the routes kept calling the old bean instance. **Cause:** a reload loads the source files of the current routes plus the changed file. A beans file with no routes is in neither, so its beans were never created again. The registry kept the instance of the old class. (Touching `beans.yaml` after the change made it work, which confirmed it.) **Fix:** - `RouteWatcherReloadStrategy` gets an optional `setBeanResources(Supplier<Collection<Resource>>)`, the files that declare beans. When a Java source is among the reload sources, those files are loaded again too. Each beans file unbinds and binds its beans again, so every bean is created from the new classes. - All beans are recreated, not only those whose class changed: bean A calling bean B needs the new instance of B. - camel-main sets the supplier from the model's custom beans, which remember their resource. - The trigger is a `.java` source in the reload, not the compiled-resources list in the registry. That list is not there yet on the first reload, because the startup compile runs before the reload strategy is registered. **Test:** `RouteReloadBeanClassTest` (camel-yaml-dsl). A route calls `greeter`, `greeter` calls `punctuation`, and only `Punctuation.java` changes. The route must answer with the new punctuation. Without the fix it fails with the old text. All `RouteReload*` tests pass. **Checked by hand** with the quick-start/routes example: two edits of `Greeter.java` under `camel run --dev` each show the new text on the reload they trigger. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m -- 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]
