[ 
https://issues.apache.org/jira/browse/CAMEL-26444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18136039#comment-18136039
 ] 

Claus Ibsen commented on CAMEL-26444:
-------------------------------------

Fixed via https://github.com/apache/camel/pull/28789

_Claude Code on behalf of Claus Ibsen_

> camel-core - a failed reload restores nothing until the first successful 
> reload since start (follow-up to CAMEL-24899)
> ----------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-26444
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26444
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 4.23.0
>            Reporter: Serdar Gökay
>            Assignee: Serdar Gökay
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> CAMEL-24899 keeps "the last successfully loaded route definitions per source" 
> and adds them back when a reload of that source fails. The routes loaded at 
> startup are not remembered, though: {{RouteWatcherReloadStrategy}} fills 
> {{lastGoodContent}} only in {{rememberContent}}, after a successful 
> {{updateRoutes}} in {{onRouteReload}}. Until the first successful reload 
> since start, a failed reload has nothing to restore the changed file from.
> Code (same on main at 31542c32):
> * {{lastGoodContent}} is filled only here: 
> https://github.com/apache/camel/blob/31542c323cb0fa4f351151cd86b517f108efbb9d/core/camel-support/src/main/java/org/apache/camel/support/RouteWatcherReloadStrategy.java#L667
> * the empty restore: 
> https://github.com/apache/camel/blob/31542c323cb0fa4f351151cd86b517f108efbb9d/core/camel-support/src/main/java/org/apache/camel/support/RouteWatcherReloadStrategy.java#L818-L822
> h3. Reproduce (camel run --dev, 4.23.0)
> Checked with camel-launcher 4.23.0 on Java 21.
> {{only.camel.yaml}}:
> {code:yaml}
> - route:
>     id: only
>     from:
>       uri: "timer:only?period=1000"
>       steps:
>         - log: "ONLY v1"
> {code}
> # {{camel run only.camel.yaml --dev}}: "ONLY v1" every second.
> # Save the file with {{timer:only?period=1000&noSuchOption=1}} as the first 
> save after start: "Reload failed and there are no previous routes to restore: 
> the application runs without routes until the file is fixed". The timer stops.
> # Save it corrected, with the log text "ONLY v2": "ONLY v2" every second.
> # Save it broken again: "The previous routes were restored (1 route(s) 
> running, 1 from the last loaded content of the changed file)". "ONLY v2" 
> keeps ticking.
> Expected: step 2 behaves like step 4. The routes loaded at startup are the 
> last successfully loaded definitions, so the first broken save restores them 
> as later ones do.
> h3. On-demand reload
> {{RouteOnDemandReloadStrategy}} ({{camel run --source-dir}}, 
> {{/q/dev/reload?reload=true}}) passes every file as changed. 
> {{restorePreviousRoutes}} leaves out every failed resource, which on this 
> path is every file, so the first failed reload since start restores no file 
> at all, not only the changed one. Which routes still run afterwards depends 
> on how far the load got before it failed.
> h3. Second observation: the warning and the running routes disagree
> When there is nothing to restore, {{restorePreviousRoutes}} logs the warning 
> and returns, without removing the routes that the partial load created before 
> it failed. {{multi.camel.yaml}} with two timer routes {{m1}} and {{m2}}, 
> started with {{camel run multi.camel.yaml --dev}}; the first save after start 
> adds {{noSuchOption=1}} to {{m2}} only. The log says "the application runs 
> without routes until the file is fixed", but {{m1}} keeps ticking, and on 
> shutdown Camel stops it ("Routes stopped (total:1) Stopped m1"). Either the 
> partially loaded routes should be removed, or the message should name the 
> routes that still run.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to