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

   ## What
   
   CAMEL-26943. In dev mode a failed reload restores the routes that ran 
before. The failed file goes back from the content that last loaded, which is 
kept in memory (CAMEL-24899, CAMEL-26444). With `camel run hello.camel.yaml 
--dev`, the next save of the fixed file then failed:
   
   ```
   WARN  Reload failed due to: Unknown node id: lgo. The previous routes were 
restored (1 route(s) running, 1 from the last loaded content of the changed 
file); the changed file loads on its next save
   WARN  Reload failed and the previous routes could not be restored due to: 
Failed to start route: hello because: duplicate route id detected hello. ...
   ```
   
   Every later save failed the same way, until a restart.
   
   The version from memory was made with `ResourceHelper.fromBytes(location, 
content)`, so its URI was made from the location: `file:hello.camel.yaml`. The 
file on disk has the URI `file:/.../hello.camel.yaml`. A reload uses the URI to 
tell which running routes came from the saved file. It did not see that the 
routes from memory came from it, so it loaded both.
   
   In a folder with a space in its name, the URI could not be made from the 
location at all (`Illegal character in path`). The next save failed on that 
before any route was removed, so the version from memory kept running until a 
restart.
   
   ## Fix
   
   The version from memory has the URI of the file it stands for. It keeps the 
scheme `mem`, the location and the content. With an absolute folder (the tests 
so far, and Camel Main), the URI made from the location was already the URI of 
the file, so nothing changes there.
   
   ## Tests
   
   - `RouteReloadRollbackTest` (camel-yaml-dsl, with the other restore tests): 
the only route file is saved broken, then fixed. The fixed version runs, as the 
only route. This is tested in a folder under `target/` given as a relative 
path, and in a folder with a space in its name. Both fail without the fix: one 
on a duplicate route id, the other on an illegal character in the path.
   - The reload tests of camel-core (26), camel-main (9), camel-xml-io-dsl (3) 
and camel-yaml-dsl (27) pass.
   - `camel run hello.camel.yaml --dev`, with the camel-support jar of this PR 
in the camel-launcher: break the file (`lgo`) and the previous version is 
restored; fix it and the fixed version runs (`Routes reloaded summary (total:1 
started:1 changed:1)`). The camel-launcher without this PR fails as above.
   
   No backport: the restore from memory came in 4.23.0 (CAMEL-24860, 
CAMEL-24899).
   
   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_012nJsFsjqqFiwroeHRWaKbS
   


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