davsclaus commented on code in PR #28778:
URL: https://github.com/apache/camel/pull/28778#discussion_r4433335338


##########
dsl/camel-jbang/camel-launcher/src/main/java/org/apache/camel/dsl/jbang/launcher/selfupdate/UpdateChecker.java:
##########
@@ -156,22 +181,32 @@ private static Properties readCache(Path cacheFile) {
         return props;
     }
 
-    // Runs on a daemon thread; any failure (network, timeout, parse) is 
swallowed, but last_checked is still
-    // updated so a persistent failure doesn't retry on every single 
invocation.
-    private static void refreshCache(Path cacheFile, Pin pin) {
+    // Writes last_checked (and the target) before the fetch, so that a 
persistent failure, or a fetch that the JVM
+    // stops, doesn't retry on every single invocation.
+    private static Properties markChecked(Path cacheFile, String target) {
         Properties props = readCache(cacheFile);
-        String target = targetOf(pin);
         if (!target.equals(props.getProperty(TARGET_KEY, LATEST_TARGET))) {
             // The cached version was resolved for another target (the pin 
changed): never compare against it.
             props.remove("latest_version");
         }
         props.setProperty(TARGET_KEY, target);
         props.setProperty("last_checked", 
Long.toString(System.currentTimeMillis()));
-        try {
-            props.setProperty("latest_version", 
resolve(ManifestFetcher.fromEnvironment(), pin));
+        writeCache(cacheFile, props);
+        return props;
+    }
+
+    // Runs on a daemon thread; any failure (network, timeout, parse) is 
swallowed, keeping whatever latest_version (if
+    // any) was already cached.
+    private static void refreshCache(Path cacheFile, Properties props, Pin 
pin) {
+        try (ManifestFetcher fetcher = ManifestFetcher.fromEnvironment()) {
+            props.setProperty("latest_version", resolve(fetcher, pin));
         } catch (Exception e) {
-            // Network/timeout/parse failure: keep whatever latest_version (if 
any) was already cached.
+            return;

Review Comment:
   Restored in 0029418c177a: the catch block keeps the old sentence, and adds 
that `markChecked` already wrote `last_checked`, so the next run doesn't retry.
   
   _Claude Code on behalf of davsclaus (Claus Ibsen)_



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