diff --git a/.gitignore b/.gitignore index 0526cc2..7034578 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,3 @@ /*/target/ /target/ core/src/main/java/com/threerings/getdown/data/Build.java - -# IntelliJ IDEA -.idea/ -*.iml -*.ipr -*.iws diff --git a/core/src/main/java/com/threerings/getdown/data/Application.java b/core/src/main/java/com/threerings/getdown/data/Application.java index 6e45757..75f23b0 100644 --- a/core/src/main/java/com/threerings/getdown/data/Application.java +++ b/core/src/main/java/com/threerings/getdown/data/Application.java @@ -32,7 +32,8 @@ import static com.threerings.getdown.Log.log; import static java.nio.charset.StandardCharsets.UTF_8; /** - * Parses and provide access to the information contained in the {@code getdown.txt} configuration file. + * Parses and provide access to the information contained in the getdown.txt + * configuration file. */ public class Application { @@ -449,7 +450,9 @@ public class Application return null; } - String vmfile = _javaLocalDir.getName() + ".jar"; + // take extension from java location + String vmfileExt = _javaLocation.substring(_javaLocation.lastIndexOf('.')); + String vmfile = _javaLocalDir.getName() + vmfileExt; try { URL remote = new URL(createVAppBase(_targetVersion), encodePath(_javaLocation)); return new Resource(vmfile, remote, getLocalPath(vmfile), @@ -874,7 +877,7 @@ public class Application } /** - * Attempts to redownload the {@code getdown.txt} file based on information parsed from a + * Attempts to redownload the getdown.txt file based on information parsed from a * previous call to {@link #init}. */ public void attemptRecovery (StatusDisplay status) @@ -885,7 +888,7 @@ public class Application } /** - * Downloads and replaces the {@code getdown.txt} and {@code digest.txt} files with + * Downloads and replaces the getdown.txt and digest.txt files with * those for the target version of our application. */ public void updateMetadata () @@ -932,7 +935,7 @@ public class Application public Process createProcess (boolean optimum) throws IOException { - List args = new ArrayList<>(); + ArrayList args = new ArrayList<>(); // reconstruct the path to the JVM args.add(LaunchUtil.getJVMBinaryPath(_javaLocalDir, _windebug || optimum)); @@ -1132,8 +1135,8 @@ public class Application } /** - * Loads the {@code digest.txt} file and verifies the contents of both that file and the - * {@code getdown.text} file. Then it loads the {@code version.txt} and decides + * Loads the digest.txt file and verifies the contents of both that file and the + * getdown.text file. Then it loads the version.txt and decides * whether or not the application needs to be updated or whether we can proceed to verification * and execution. * @@ -1552,6 +1555,7 @@ public class Application if (!sig.verify(Base64.decode(signature, Base64.DEFAULT))) { log.info("Signature does not match", "cert", cert.getPublicKey()); + continue; } else { log.info("Signature matches", "cert", cert.getPublicKey()); validated++; diff --git a/core/src/main/java/com/threerings/getdown/util/Config.java b/core/src/main/java/com/threerings/getdown/util/Config.java index 94588aa..4fc5e16 100644 --- a/core/src/main/java/com/threerings/getdown/util/Config.java +++ b/core/src/main/java/com/threerings/getdown/util/Config.java @@ -237,7 +237,7 @@ public class Config */ public String getString (String name, String def) { String value = (String)_data.get(name); - return StringUtil.isBlank(value) ? def : value; + return value == null ? def : value; } /** diff --git a/core/src/main/java/com/threerings/getdown/util/LaunchUtil.java b/core/src/main/java/com/threerings/getdown/util/LaunchUtil.java index 99cc702..0c33c29 100644 --- a/core/src/main/java/com/threerings/getdown/util/LaunchUtil.java +++ b/core/src/main/java/com/threerings/getdown/util/LaunchUtil.java @@ -17,19 +17,19 @@ import static com.threerings.getdown.Log.log; * Useful routines for launching Java applications from within other Java * applications. */ -public final class LaunchUtil +public class LaunchUtil { /** The default directory into which a local VM installation should be unpacked. */ public static final String LOCAL_JAVA_DIR = "java_vm"; /** - * Writes a {@code version.txt} file into the specified application directory and + * Writes a version.txt file into the specified application directory and * attempts to relaunch Getdown in that directory which will cause it to upgrade to the newly * specified version and relaunch the application. * * @param appdir the directory in which the application is installed. * @param getdownJarName the name of the getdown jar file in the application directory. This is - * probably {@code getdown-pro.jar} or getdown-retro-pro.jar if you are using + * probably getdown-pro.jar or getdown-retro-pro.jar if you are using * the results of the standard build. * @param newVersion the new version to which Getdown will update when it is executed. * @param javaLocalDir JRE location within appdir, falls back to {@link #LOCAL_JAVA_DIR} in case if null is passed @@ -40,7 +40,7 @@ public final class LaunchUtil * after making this call as it will be upgraded and restarted. If false is returned, the * application should tell the user that they must restart the application manually. * - * @exception IOException thrown if we were unable to create the {@code version.txt} file + * @exception IOException thrown if we were unable to create the version.txt file * in the supplied application directory. If the version.txt file cannot be created, restarting * Getdown will not cause the application to be upgraded, so the application will have to * resort to telling the user that it is in a bad way. @@ -64,9 +64,7 @@ public final class LaunchUtil // do the deed String[] args = { getJVMBinaryPath(new File(appdir, StringUtil.isBlank(javaLocalDir) ? LOCAL_JAVA_DIR : javaLocalDir), false), - "-jar", - pro.toString(), - appdir.getPath() + "-jar", pro.toString(), appdir.getPath() }; log.info("Running " + StringUtil.join(args, "\n ")); try { @@ -146,7 +144,8 @@ public final class LaunchUtil if (newgd.renameTo(curgd)) { FileUtil.deleteHarder(oldgd); // yay! try { - // copy the moved file back to newgd so that we don't end up downloading another copy next time + // copy the moved file back to newgd so that we don't end up + // downloading another copy next time FileUtil.copy(curgd, newgd); } catch (IOException e) { log.warning("Error copying updated Getdown back: " + e); @@ -177,23 +176,23 @@ public final class LaunchUtil public static boolean mustMonitorChildren () { String osname = System.getProperty("os.name", "").toLowerCase(Locale.ROOT); - return osname.contains("windows 98") || osname.contains("windows me"); + return (osname.indexOf("windows 98") != -1 || osname.indexOf("windows me") != -1); } /** * Returns true if we're running in a JVM that identifies its operating system as Windows. */ - public static boolean isWindows () { return _isWindows; } + public static final boolean isWindows () { return _isWindows; } /** * Returns true if we're running in a JVM that identifies its operating system as MacOS. */ - public static boolean isMacOS () { return _isMacOS; } + public static final boolean isMacOS () { return _isMacOS; } /** * Returns true if we're running in a JVM that identifies its operating system as Linux. */ - public static boolean isLinux () { return _isLinux; } + public static final boolean isLinux () { return _isLinux; } /** * Checks whether a Java Virtual Machine can be located in the supplied path. @@ -231,10 +230,11 @@ public final class LaunchUtil static { try { String osname = System.getProperty("os.name"); - osname = osname == null ? "" : osname; - _isWindows = osname.contains("Windows"); - _isMacOS = osname.contains("Mac OS") || osname.contains("MacOS"); - _isLinux = osname.contains("Linux"); + osname = (osname == null) ? "" : osname; + _isWindows = (osname.indexOf("Windows") != -1); + _isMacOS = (osname.indexOf("Mac OS") != -1 || + osname.indexOf("MacOS") != -1); + _isLinux = (osname.indexOf("Linux") != -1); } catch (Exception e) { // can't grab system properties; we'll just pretend we're not on any of these OSes } diff --git a/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java b/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java index 4ae0f80..d5be7b3 100644 --- a/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java +++ b/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java @@ -75,7 +75,7 @@ public abstract class Getdown extends Thread // welcome to hell, where java can't cope with a classpath that contains jars that live // in a directory that contains a !, at least the same bug happens on all platforms String dir = envc.appDir.toString(); - if (".".equals(dir)) { + if (dir.equals(".")) { dir = System.getProperty("user.dir"); } String errmsg = "The directory in which this application is installed:\n" + dir + @@ -130,7 +130,7 @@ public abstract class Getdown extends Thread File instdir = _app.getLocalPath(""); if (!instdir.canWrite()) { String path = instdir.getPath(); - if (".".equals(path)) { + if (path.equals(".")) { path = System.getProperty("user.dir"); } fail(MessageUtil.tcompose("m.readonly_error", path)); @@ -824,7 +824,7 @@ public abstract class Getdown extends Thread } /** - * Update the status to indicate getdown has failed for the reason in {@code message}. + * Update the status to indicate getdown has failed for the reason in message. */ protected void fail (String message) {