gnodet-bot commented on code in PR #27774:
URL: https://github.com/apache/camel/pull/27774#discussion_r4257580213
##########
core/camel-support/src/main/java/org/apache/camel/support/RouteWatcherReloadStrategy.java:
##########
@@ -378,10 +378,15 @@ protected void onRouteReload(Collection<Resource>
resources, boolean removeEvery
// that exist, so its routes are removed like those of a
changed file, CAMEL-25427)
// (a route from a templated route needs the file with the
route template, and the file with the
// templated route, CAMEL-25598; a route from a Kamelet is
created again by its parent route)
+ // (the file with the templated route is only loaded again
when its route template comes from a file:
+ // a route template added from Java is removed below and
nothing adds it again, so loading the
+ // templated route would fail the whole reload, CAMEL-25616)
getCamelContext().getRoutes().forEach(r -> {
if (!r.isCreatedByKamelet()) {
addRouteSource(resources, sources,
r.getSourceResource());
- addRouteSource(resources, sources,
r.getTemplatedRouteResource());
+ if (r.getSourceResource() != null) {
+ addRouteSource(resources, sources,
r.getTemplatedRouteResource());
+ }
Review Comment:
💡 **Suggestion (optional):** The guard uses `r.getSourceResource() != null`
as a proxy for "this template comes from a file" (as opposed to being defined
in Java). A brief comment would make the intent explicit:
```suggestion
if (r.getSourceResource() != null) { // only
file-backed templates: Java-defined ones are rebuilt below
addRouteSource(resources, sources,
r.getTemplatedRouteResource());
}
```
--
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]