[
https://issues.apache.org/jira/browse/CAMEL-24866?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen resolved CAMEL-24866.
---------------------------------
Resolution: Fixed
> camel-support - route reload fails with duplicate route id when a new file is
> added next to a file with several routes
> ----------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-24866
> URL: https://issues.apache.org/jira/browse/CAMEL-24866
> Project: Camel
> Issue Type: Bug
> Components: camel-core, camel-jbang
> Affects Versions: 4.22.0
> Reporter: Claus Ibsen
> Priority: Major
> Fix For: 4.23.0
>
>
> Reproduce with a running dev-mode app whose route file has more than one
> route, for example {{camel run --source-dir=. --dev}} with a
> {{sql.camel.yaml}} holding three routes. Add a second route file to the
> directory:
> {code}
> - route:
> id: hello
> from:
> uri: timer
> parameters:
> timerName: hello
> period: 3000
> steps:
> - log:
> message: "hello from a new file"
> {code}
> The reload stops all routes and then fails, so nothing runs until the next
> successful save:
> {noformat}
> WARN FileWatcherResourceReloadStrategy : Error reloading routes from file:
> .../hello.camel.yaml
> org.apache.camel.FailedToStartRouteException: Failed to start route:
> create-table because: duplicate route id detected create-table. Please
> correct ids to be unique among all your routes.
> at
> org.apache.camel.impl.engine.DefaultRoutesLoader.updateRoutes(DefaultRoutesLoader.java:308)
> at
> org.apache.camel.support.RouteWatcherReloadStrategy.onRouteReload(RouteWatcherReloadStrategy.java:319)
> {noformat}
> Cause: {{RouteWatcherReloadStrategy.onRouteReload}} collects the sources to
> load again from {{getCamelContext().getRoutes()}}, adding each route's source
> resource to a list and only skipping the changed resource. A file with N
> routes is added N times, {{DefaultRoutesLoader.updateRoutes}} loads it N
> times, and the second copy trips the duplicate route id check. A change to an
> existing file is not affected because that file is the excluded one; the
> failure needs a new file (or a properties file when the reload is triggered
> with all routes) next to a multi-route file.
> Fix: add a source only once per location (the same comparison
> {{equalResourceLocation}} already uses).
> Found while running the camel-jbang-mcp server stepwise benchmark: the model
> added a route file next to the example's three-route file and the app went
> down with this error.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)