JAL-3631 Harden defence against looping getdown relaunches. Null checked in HttpUtils...
authorBen Soares <b.soares@dundee.ac.uk>
Mon, 1 Jul 2024 01:05:00 +0000 (02:05 +0100)
committerBen Soares <b.soares@dundee.ac.uk>
Mon, 1 Jul 2024 01:05:00 +0000 (02:05 +0100)
getdown/lib/getdown-core.jar
getdown/lib/getdown-launcher-local.jar
getdown/lib/getdown-launcher.jar
getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java
getdown/src/getdown/core/src/main/java/jalview/util/HttpUtils.java
getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/GetdownApp.java
j11lib/getdown-core.jar
j8lib/getdown-core.jar
src/jalview/util/HttpUtils.java

index 323bf3b..46629c1 100644 (file)
Binary files a/getdown/lib/getdown-core.jar and b/getdown/lib/getdown-core.jar differ
index b4b2130..26da13e 100644 (file)
Binary files a/getdown/lib/getdown-launcher-local.jar and b/getdown/lib/getdown-launcher-local.jar differ
index b451a80..e1d9f8e 100644 (file)
Binary files a/getdown/lib/getdown-launcher.jar and b/getdown/lib/getdown-launcher.jar differ
index a9734a8..12c2b64 100644 (file)
@@ -295,7 +295,6 @@ public class Application
        _envc = envc;
        _config = getLocalPath(envc.appDir, CONFIG_FILE);
        _backupConfig = getLocalPath(envc.appDir, BACKUP_CONFIG_DIR + File.separator + CONFIG_FILE);
-       log.warning("##### SET _config to", "_config", _config.getAbsolutePath());
     }
 
     /**
@@ -596,14 +595,6 @@ public class Application
      * during its parsing.
      */
     public Config init (boolean checkPlatform) throws IOException {
-      /*#####
-      return init(checkPlatform, false);
-    }
-    
-    public Config init (boolean checkPlatform, boolean secondCall)
-        throws IOException
-    {
-    */
         if (_initialised && _initialisedConfig != null)
         {
           return _initialisedConfig;
@@ -659,7 +650,6 @@ public class Application
         
         // merge the locator file config into config (or replace config with)
         if (locatorConfig != null) {
-          //##### if (config == null || locatorConfig.getBoolean(LOCATOR_FILE_EXTENSION+"_replace") || (locatorConfig.hasValue("appbase") && !secondCall)) {
           if (config == null || locatorConfig.getBoolean(LOCATOR_FILE_EXTENSION+"_replace")) {
             config = locatorConfig;
                        log.warning("Replacing config with locator file", LOCATOR_FILE_EXTENSION+"_file", locatorConfig);
@@ -683,24 +673,6 @@ public class Application
         // process, our caller can use the appbase to download a new configuration file
         _appbase = config.getString("appbase");
         
-        /* #####
-        // see if locatorConfig override
-        if (!secondCall && locatorConfig != null && !StringUtil.isBlank(locatorConfig.getString("appbase"))) {
-          String lAppbase = locatorConfig.getString("appbase");
-          if (lAppbase != null && !lAppbase.endsWith("/")) {
-              lAppbase = lAppbase + "/";
-          }
-          if (lAppbase != null && !lAppbase.equals(_appbase)) {
-            _appbase = lAppbase;
-            // get new getdown.txt
-            log.warning("Attempting to download new getdown.txt from " + _appbase + " and use that");
-            updateMetadata();
-            setLocatorFile(null);
-            return init(checkPlatform, true);
-          }
-        }
-        */
-        
         if (_appbase == null) {
             throw new RuntimeException("m.missing_appbase");
         }
@@ -2238,6 +2210,11 @@ public class Application
     }
     
     public boolean updateMetadataAndRelaunch(String newAppbase, Class startClass, String locatorFileArg, String[] argv, List<Note> notes) {
+      if (Boolean.parseBoolean(System.getProperty(NOJVLAPPBASERELAUNCH))) {
+        notes.add(Note.warn("System property " + NOJVLAPPBASERELAUNCH + " is set, not attempting jvl appbase relaunch"));
+        return false;
+      }
+      
       _appbase = newAppbase;
       try {
         updateMetadata();
@@ -2268,6 +2245,7 @@ public class Application
         removeJvmArgs.add("-Xdock:name=");
         addJvmArgs.add("-Xdock:name=" + ( appName != null ? appName : ChannelProperties.FALLBACK_APPNAME ));
       }
+      addJvmArgs.add("-D" + NOJVLAPPBASERELAUNCH + "=true");
       
       List<String> removeArgs = new ArrayList<>();
       if (locatorFileArg != null) {
@@ -2365,4 +2343,6 @@ public class Application
     public static String i4jVersion = null;
     private String jvmmempc = null;
     private String jvmmemmax = null;
+    
+    private static final String NOJVLAPPBASERELAUNCH = "launcher.NO_JVL_APPBASE_RELAUNCH";
 }
index 44880a0..ec35948 100644 (file)
@@ -244,6 +244,10 @@ public class HttpUtils
    */
   public static boolean isJalviewSchemeUri(String jalviewUriString)
   {
+    if (jalviewUriString == null)
+    {
+      return false;
+    }
     URI jalviewUri;
     try
     {
index 17f5949..1283f11 100644 (file)
@@ -315,12 +315,10 @@ public class GetdownApp
   
     String locatorFile = Application.getLocatorFile();
     if (locatorFile != null) {
-      String lfAppbase = app.getApplication().getEnvConfig().getLocatorFileAppBase(locatorFile);
-      if (lfAppbase != null && !lfAppbase.equals(app.getApplication().getAppbase())) {
+      String lfAppbase = HttpUtils.equivalentJalviewUrl(app.getApplication().getEnvConfig().getLocatorFileAppBase(locatorFile));
+      String oldAppbase = HttpUtils.equivalentJalviewUrl(app.getApplication().getAppbase());
+      if (lfAppbase != null && !lfAppbase.equals(oldAppbase)) {
      
-      /** ###### 
-       * DO METADATA DOWNLOAD AND RESLAUNCH GETDOWN WITH DON'T RESTART PROPERTY (MAKE IT UP) HERE!
-       */
         notes = new ArrayList<>();
 
         boolean relaunched = app.getApplication().updateMetadataAndRelaunch(lfAppbase, GetdownApp.class, locatorFile, argv, notes);
index 323bf3b..46629c1 100644 (file)
Binary files a/j11lib/getdown-core.jar and b/j11lib/getdown-core.jar differ
index 323bf3b..46629c1 100644 (file)
Binary files a/j8lib/getdown-core.jar and b/j8lib/getdown-core.jar differ
index 44880a0..ec35948 100644 (file)
@@ -244,6 +244,10 @@ public class HttpUtils
    */
   public static boolean isJalviewSchemeUri(String jalviewUriString)
   {
+    if (jalviewUriString == null)
+    {
+      return false;
+    }
     URI jalviewUri;
     try
     {