From: Ben Soares Date: Mon, 1 Jul 2024 01:05:00 +0000 (+0100) Subject: JAL-3631 Harden defence against looping getdown relaunches. Null checked in HttpUtils... X-Git-Tag: Release_2_11_4_0~24^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=50ba227f13bb12d416af472b0271390395c39e9e;p=jalview.git JAL-3631 Harden defence against looping getdown relaunches. Null checked in HttpUtils. Remove unnecessary code in getdown --- diff --git a/getdown/lib/getdown-core.jar b/getdown/lib/getdown-core.jar index 323bf3b..46629c1 100644 Binary files a/getdown/lib/getdown-core.jar and b/getdown/lib/getdown-core.jar differ diff --git a/getdown/lib/getdown-launcher-local.jar b/getdown/lib/getdown-launcher-local.jar index b4b2130..26da13e 100644 Binary files a/getdown/lib/getdown-launcher-local.jar and b/getdown/lib/getdown-launcher-local.jar differ diff --git a/getdown/lib/getdown-launcher.jar b/getdown/lib/getdown-launcher.jar index b451a80..e1d9f8e 100644 Binary files a/getdown/lib/getdown-launcher.jar and b/getdown/lib/getdown-launcher.jar differ diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java index a9734a8..12c2b64 100644 --- a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java @@ -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 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 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"; } diff --git a/getdown/src/getdown/core/src/main/java/jalview/util/HttpUtils.java b/getdown/src/getdown/core/src/main/java/jalview/util/HttpUtils.java index 44880a0..ec35948 100644 --- a/getdown/src/getdown/core/src/main/java/jalview/util/HttpUtils.java +++ b/getdown/src/getdown/core/src/main/java/jalview/util/HttpUtils.java @@ -244,6 +244,10 @@ public class HttpUtils */ public static boolean isJalviewSchemeUri(String jalviewUriString) { + if (jalviewUriString == null) + { + return false; + } URI jalviewUri; try { diff --git a/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/GetdownApp.java b/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/GetdownApp.java index 17f5949..1283f11 100644 --- a/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/GetdownApp.java +++ b/getdown/src/getdown/launcher/src/main/java/com/threerings/getdown/launcher/GetdownApp.java @@ -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); diff --git a/j11lib/getdown-core.jar b/j11lib/getdown-core.jar index 323bf3b..46629c1 100644 Binary files a/j11lib/getdown-core.jar and b/j11lib/getdown-core.jar differ diff --git a/j8lib/getdown-core.jar b/j8lib/getdown-core.jar index 323bf3b..46629c1 100644 Binary files a/j8lib/getdown-core.jar and b/j8lib/getdown-core.jar differ diff --git a/src/jalview/util/HttpUtils.java b/src/jalview/util/HttpUtils.java index 44880a0..ec35948 100644 --- a/src/jalview/util/HttpUtils.java +++ b/src/jalview/util/HttpUtils.java @@ -244,6 +244,10 @@ public class HttpUtils */ public static boolean isJalviewSchemeUri(String jalviewUriString) { + if (jalviewUriString == null) + { + return false; + } URI jalviewUri; try {