[
https://issues.apache.org/jira/browse/CAMEL-25032?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18119550#comment-18119550
]
Claus Ibsen commented on CAMEL-25032:
-------------------------------------
PR: https://github.com/apache/camel/pull/26907
> Dev mode: a route saved together with a property it uses fails to reload and
> keeps running the previous version
> ---------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-25032
> URL: https://issues.apache.org/jira/browse/CAMEL-25032
> Project: Camel
> Issue Type: Bug
> Components: camel-core
> Reporter: Claus Ibsen
> Priority: Major
>
> 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 file and the properties file are reloaded one after the other,
> and 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:
> {noformat}
> 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)
> {noformat}
> Three milliseconds later the properties are reloaded, and the property is
> there. But the route 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 restored content, not the file on
> disk. The application keeps logging the old message, and "Routes reloaded
> summary (total:1 started:1)" says everything is fine. 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 the case 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 -- see
> the message, add the property -- and today it does not bring the route back.
> Found while measuring how well a local model can write Camel routes with 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.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)