JAL-3543 Conditional reporting of Install4j and Getdown versions if null
authorBen Soares <bsoares@dundee.ac.uk>
Thu, 27 Feb 2020 16:09:30 +0000 (16:09 +0000)
committerBen Soares <bsoares@dundee.ac.uk>
Thu, 27 Feb 2020 16:09:30 +0000 (16:09 +0000)
src/jalview/bin/Cache.java
src/jalview/bin/Jalview.java

index 3b9b98a..35d6aa3 100755 (executable)
@@ -1075,6 +1075,24 @@ public class Cache
   }
 
   /**
+   * Initial logging information helper for various versions output
+   * 
+   * @param prefix
+   * @param value
+   * @param defaultValue
+   */
+  private static void appendIfNotNull(StringBuilder sb, String prefix,
+          String value, String suffix, String defaultValue)
+  {
+    if (value == null && defaultValue == null)
+    {
+      return;
+    }
+    String line = prefix + (value != null ? value : defaultValue) + suffix;
+    sb.append(line);
+  }
+
+  /**
    * 
    * @return Jalview version, build details and JVM platform version for console
    */
@@ -1092,20 +1110,17 @@ public class Cache
     sb.append("\n");
     sb.append(System.getProperty("os.arch") + " " + System.getProperty("os.name") + " " + System.getProperty("os.version"));
     sb.append("\n");
-    sb.append("Install4j version: "
-            + System.getProperty("sys.install4jVersion"));
-    sb.append("\n");
-    sb.append("Install4j template version: "
-            + System.getProperty("installer_template_version"));
-    sb.append("\n");
-    sb.append(
-            "Launcher version: " + System.getProperty("launcher_version"));
-    sb.append("\n");
+    appendIfNotNull(sb, "Install4j version: ",
+            System.getProperty("sys.install4jVersion"), "\n", null);
+    appendIfNotNull(sb, "Install4j template version: ",
+            System.getProperty("installer_template_version"), "\n", null);
+    appendIfNotNull(sb, "Launcher version: ",
+            System.getProperty("launcher_version"), "\n", null);
     if (jalview.bin.Cache.getDefault("VERSION", "TEST").equals("DEVELOPMENT")) {
-      sb.append("Getdown appdir: " + System.getProperty("getdownappdir"));
-      sb.append("\n");
-      sb.append("Java home: " + System.getProperty("java.home"));
-      sb.append("\n");
+      appendIfNotNull(sb, "Getdown appdir: ",
+              System.getProperty("getdownappdir"), "\n", null);
+      appendIfNotNull(sb, "Java home: ", System.getProperty("java.home"),
+              "\n", "unknown");
     }
     return sb.toString();
   }
index a5cf48f..3cae900 100755 (executable)
@@ -198,17 +198,24 @@ public class Jalview
   {
     System.setSecurityManager(null);
     System.out
-            .println("Java version: " + System.getProperty("java.version"));
+            .println("Java version: "
+                    + System.getProperty("java.version"));
     System.out.println("Java Home: " + System.getProperty("java.home"));
     System.out.println(System.getProperty("os.arch") + " "
             + System.getProperty("os.name") + " "
             + System.getProperty("os.version"));
-    System.out.println("Install4j version: "
-            + System.getProperty("sys.install4jVersion"));
-    System.out.println("Install4j template version: "
-            + System.getProperty("installer_template_version"));
-    System.out.println(
-            "Launcher version: " + System.getProperty("launcher_version"));
+    String val = System.getProperty("sys.install4jVersion");
+    if (val != null) {
+    System.out.println("Install4j version: " + val);
+    }
+    val = System.getProperty("installer_template_version");
+    if (val != null) {
+      System.out.println("Install4j template version: " + val);
+    }
+    val = System.getProperty("launcher_version");
+    if (val != null) {
+      System.out.println("Launcher version: " + val);
+    }
 
     // report Jalview version
     Cache.loadBuildProperties(true);
@@ -414,6 +421,7 @@ public class Jalview
       BioJsHTMLOutput.updateBioJS();
     }
 
+    Cache.log.info("CHECKPOINT 1");
     // Move any new getdown-launcher-new.jar into place over old
     // getdown-launcher.jar
     String appdirString = System.getProperty("getdownappdir");
@@ -438,6 +446,7 @@ public class Jalview
     DataSourceType protocol = null;
     FileLoader fileLoader = new FileLoader(!headless);
 
+    Cache.log.info("CHECKPOINT 2");
     String groovyscript = null; // script to execute after all loading is
     // completed one way or another
     // extract groovy argument and execute if necessary