Claus Ibsen created CAMEL-26943:
-----------------------------------

             Summary: camel-core - dev mode: after a failed reload, the reload 
of the fixed file fails with a duplicate route id
                 Key: CAMEL-26943
                 URL: https://issues.apache.org/jira/browse/CAMEL-26943
             Project: Camel
          Issue Type: Bug
          Components: camel-core
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while trying camel cmd reload --wait (CAMEL-26939) on 2026-11-13, with 
the 4.24.0-SNAPSHOT camel-launcher on macOS, JDK 25. Also on main without that 
change, with the scan of dev mode only.

Steps:
{code}
- route:
    id: hello
    from:
      uri: timer:tick
      steps:
        - log:
            message: "Hello base"
{code}
* camel run hello.camel.yaml --dev
* change {{log}} to {{lgo}} and save: "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". 
Good so far.
* fix it ({{lgo}} back to {{log}}, and "Hello fixed") and save: "Reload failed 
and the previous routes could not be restored due to: Failed to start route: 
hello because: duplicate route id detected hello". The old route keeps running, 
and every later save of the file fails the same way, until a restart.

Cause (read in the code, not yet proven by a test): 
{{RouteWatcherReloadStrategy.restorePreviousRoutes}} brings the failed file 
back from its last good content with 
{{ResourceHelper.fromBytes(rs.getLocation(), content)}}, a {{mem}} resource 
whose URI is the location as given ({{file:hello.camel.yaml}}, relative). At 
the next reload, {{addRouteSources}} skips the source of a running route only 
when {{equalResourceLocation}} finds it among the changed resources, and that 
compares {{getURI()}}: the file from disk has an absolute URI 
({{file:/.../hello.camel.yaml}}). So the restored route is not seen as coming 
from the changed file: its old content is loaded again next to the new file, 
and both define the route {{hello}}.

Fix idea: give the in-memory resource the URI of the file it stands for, or 
compare file locations by their absolute, normalized path. A test in 
camel-core: a route file in a relative folder, a broken save, then a fixed save 
that must reload.

This matters more for AI agents, whose loop is edit, reload, read the error, 
fix: the fix never loads.

_Claude Code on behalf of Claus Ibsen_



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

Reply via email to