davsclaus opened a new pull request, #26907:
URL: https://github.com/apache/camel/pull/26907
In dev mode a reload is per file, and the file watcher hands the changed
files of one batch to the reload strategy in whatever order the OS reported
them. A route is built with the properties of the moment, so saving a route
together with a property it uses fails when the route goes first:
```
20:41:39.613 WARN Reload failed due to: Failed to create route: welcome at:
>>> Log[Welcome to {{shop.name}}, prices in {{shop.currency}}] <<<
... Property with key [shop.currency] not found in
properties from text: Welcome to Camel Shop, prices in {{shop.currency}}
20:41:39.613 INFO Reloading properties: file:.../application.properties
20:41:39.616 INFO Routes reloaded summary (total:1 started:1)
```
Three milliseconds later the properties are reloaded and the property is
there — but the route that runs is not the saved one. The failed reload
restored the content that last ran (CAMEL-24860 / CAMEL-24899), and the route
reload that the properties change triggers reloads *that* content, not the file
on disk. The application keeps logging the old message while "Routes reloaded
summary (total:1 started:1)" says everything is fine, and only touching the
route file again brings the saved version in.
Two changes:
- `FileWatcherResourceReloadStrategy` reloads the `.properties` files of a
batch before the other files, so a route saved together with a property it uses
is built with that property in place. The sort is stable, so files of the same
kind keep their reported order.
- `RouteWatcherReloadStrategy` remembers the sources of a failed reload and,
when the properties change, loads those from disk again instead of reloading
the restored content. This covers what the ordering cannot: a route saved on
its own that fails on a missing property, and the property added in a later
save. That is the normal way to fix the error by hand — read the message, add
the property — and today it does not bring the route back.
Tests: `FileWatcherReloadOrderTest` for the ordering (four cases, including
that the sort is stable and leaves a batch with no properties file alone), and
`RouteReloadPropertiesRetryTest` for the retry — it drives the reload callbacks
by hand, saves a route using `mock:{{shop.currency}}` before the property
exists, checks the reload fails and the previous route is restored, then adds
the property and checks the saved route is the one that runs.
Found while measuring how well a local model writes Camel routes through the
camel-jbang-mcp server: the model adds a property and uses it in the same step,
and the route silently kept running its previous version.
🤖 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]