davsclaus opened a new pull request, #28119:
URL: https://github.com/apache/camel/pull/28119

   [CAMEL-25831](https://issues.apache.org/jira/browse/CAMEL-25831): in dev 
mode, a reload whose files include a Java source also loads the files that 
declare beans again, so that their beans are created again 
(`RouteWatcherReloadStrategy`, the bean resources from the model). The file of 
a bean that was deleted stayed among them. So once the Java source of a bean 
was deleted, the next reload failed:
   
   ```
   Error reloading routes from file: ... due to: java.io.FileNotFoundException: 
src/main/java/camel/example/Greeter.java does not exist
        at 
org.apache.camel.support.RouteWatcherReloadStrategy.onRouteReload(RouteWatcherReloadStrategy.java:600)
   ```
   
   The strategy then restores the routes that ran, and takes the files of the 
failed reload into the next one. So every later reload failed too, also that of 
a changed YAML route, and the app kept the routes it had.
   
   Found in a benchmark of Oct 18-19 2026: the harness moved `Order.java` from 
`src/main/java` to the project folder between two steps, and the next change of 
the model failed to reload.
   
   ## What
   
   - The files of the beans, and the files in `RouteWatcherReloadResources` 
from the registry, are skipped when they are gone. This is what the strategy 
already did for the file of a route (`isDeletedFile`).
   
   ## Tests
   
   - New `RouteWatcherReloadDeletedBeanSourceTest` (2). It uses a routes loader 
that records the files and fails on a file that is gone, as the loaders do:
     - the file of a bean that is gone is not loaded, also on the next reload;
     - neither is a file in `RouteWatcherReloadResources` that is gone.
     - Without the fix, both fail with the `FileNotFoundException`.
   - The reload tests of camel-core pass (20).
   - End to end with `camel run --source-dir=. --dev`, a YAML route that calls 
a class from `src/main/java/camel/example/Greeter.java`, and the class moved to 
`Greeter.java` in the project folder:
     - Before: the reload failed with the `FileNotFoundException`, and a change 
of the route did not reload either.
     - After: both reload, and the changed route runs.
   
   🤖 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]

Reply via email to