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

   ## Description
   
   When a route file is saved with a mistake in dev mode, 
`RouteWatcherReloadStrategy.onRouteReload` first stops and removes every route 
(`removeAllRoutes`), then loads the new set; when that load fails, the 
exception goes to the file watcher, which logs "Error reloading routes ... This 
exception is ignored", and the application runs with no routes at all until the 
next successful save. The strategy already remembers the previous sources for 
exactly that next save; nothing used them until then. In the stepwise benchmark 
a cron route was gone for 22 seconds after a bad save, and the only log lines 
were "Pausing trigger / Deleting job".
   
   The catch now restores the previous routes: the remembered sources minus the 
failed resources are reloaded (after clearing what a partial load may have 
left), a WARN says "Reload failed: the previous routes were restored (N 
route(s) running); the changed file loads on its next save", and the exception 
is rethrown as before, so the watcher's error line, the 
`CamelContextReloadFailure` event (CAMEL-24851) and the validator's report all 
still follow. The remembered set is cleared after the restore, since the 
running routes are the last working set again. If nothing can be restored, or 
the restore itself fails, a WARN says the application runs without routes until 
the file is fixed. Only the `removeAllRoutes` mode is concerned; the 
incremental mode never removed the other routes.
   
   Pre-validating the file before removing the routes was considered: 
`preParseRoute` catches syntax but not the model errors the deserializers throw 
(`pollEnrich: {uri: ...}`, a cron endpoint without its name), and building into 
a throwaway context is heavy and has side effects. The rollback uses the 
machinery that exists and covers every kind of failure.
   
   Live check with `camel run --source-dir --dev` and two route files: the 
second saved with a mistake, the first kept logging through it (the WARN, the 
validator's report and the reload error in the log), and the fixed save brought 
both back. Upgrade guide note added.
   
   ## Tests
   
   - `RouteReloadRollbackTest` (camel-yaml-dsl, Spock, where a route file 
loader is on the test classpath): two YAML route files loaded, the strategy's 
reload callback driven by hand with a broken save of the second, the first 
route is Started again and the second is gone; the fixed save starts both.
   - camel-core reload and secret rotation tests (22), camel-main and 
camel-kamelet-main reload tests green.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj


-- 
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