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

   Fixes [CAMEL-25427](https://issues.apache.org/jira/browse/CAMEL-25427)
   
   ## Problem
   
   On-demand reload (`/q/dev/reload?reload=true`, JMX `onReload`) only passes 
the route files that exist in the source directory. When a route file had been 
removed or renamed:
   
   1. With `removeAllRoutes` (the default), 
`RouteWatcherReloadStrategy.onRouteReload` collected the source of every 
current route, including the one whose file was gone, and `updateRoutes` failed 
with `FileNotFoundException`.
   2. `restorePreviousRoutes` then tried to restore from `previousSources`, 
which also held the removed file, so the restore failed too and the application 
was left with **no routes**.
   3. `previousSources` was never cleared, so every later reload failed the 
same way until a restart.
   
   File-watcher mode was not affected: it reports a deleted file as a change, 
so the file ends up in the passed resources and is dropped by the existing 
`Files.exists` check.
   
   ## Fix
   
   A small `isDeletedFile(Resource)` helper skips sources whose `file:` 
location no longer exists. It is applied in three places:
   - the sources collected from the current routes
   - the previously attempted sources (`previousSources`)
   - the routes to restore after a failed reload
   
   The check looks at the **location on disk**, not `Resource.exists()`. A 
route restored from its last loaded content (CAMEL-24899) has an in-memory 
source that always reports `exists() == true`, even after its file is removed. 
Non-`file:` sources (classpath, in-memory without a file location) are kept as 
before.
   
   ## Tests
   
   `RouteReloadOnDemandRemovedFileTest` (camel-yaml-dsl, next to the other 
`RouteReload*Test`s):
   - `aRemovedFileRemovesItsRoutesAndTheOthersReload`: two files, delete one, 
reload on demand. The other route keeps running and a second reload also 
succeeds.
   - `aFileRestoredFromMemoryCanBeRemoved`: a broken save restores the routes 
from memory, then the broken file is deleted and the next reload succeeds.
   
   Both fail without the fix and pass with it. All `RouteReload*Test` in 
camel-yaml-dsl (11) and `*Reload*Test` in camel-core (36) pass, and a full `mvn 
clean install -DskipTests` succeeds.
   
   _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]

Reply via email to