gnodet-bot commented on code in PR #26742:
URL: https://github.com/apache/camel/pull/26742#discussion_r4071386445


##########
core/camel-support/src/main/java/org/apache/camel/support/RouteWatcherReloadStrategy.java:
##########
@@ -322,6 +327,7 @@ protected void onRouteReload(Collection<Resource> 
resources, boolean removeEvery
 
             // update okay, so clear as we do not need to remember those 
anymore
             previousSources.clear();
+            rememberContent(sources);

Review Comment:
   ⚠️ **Latent bug — `removeEverything=true` silently wipes `lastGoodContent`**
   
   At line 320-321 (pre-existing path), when `removeEverything=true`, 
`sources.clear()` is called *before* this `rememberContent(sources)` call. That 
causes `lastGoodContent.keySet().retainAll(empty_set)` inside 
`rememberContent`, which clears the entire map — erasing the fallback content 
for the next failed reload.
   
   All current callers pass `removeEverything=false`, so this doesn't fire 
today. But `onRouteReload` is `protected`, meaning subclasses can invoke it, 
and any future caller that passes `true` (e.g. "reload everything from scratch" 
mode) will silently discard the safety net added by this PR.
   
   Fix: snapshot `sources` before the clear, pass the snapshot to 
`rememberContent`:
   
   ```java
   // just in case remember this set of sources as what was attempted previously
   previousSources.clear();
   previousSources.addAll(sources);
   
   // special situation where we remove all routes
   if (removeEverything) {
       sources.clear();
   }
   
   Set<String> ids =
           
PluginHelper.getRoutesLoader(getCamelContext()).updateRoutes(sources);
   
   // update okay — remember the sources that actually ran
   previousSources.clear();
   List<Resource> ran = removeEverything ? new ArrayList<>(previousSources) : 
sources;
   rememberContent(ran);
   ```
   
   (Or simply pass `previousSources` — it already holds the pre-clear snapshot 
— but be careful `previousSources` is cleared right after, so capture it first.)



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