8081576: serviceability/sa tests fail due to LingeredApp process fails to start
authordsamersoff
Tue, 23 Jun 2015 12:30:57 +0300
changeset 31318 2f6b57472d81
parent 31317 9029b3303113
child 31319 6a96ae34c904
8081576: serviceability/sa tests fail due to LingeredApp process fails to start Summary: Provide a API to corrctly terminate LingeredApp Reviewed-by: sspitsyn
test/lib/share/classes/jdk/test/lib/apps/LingeredApp.java
--- a/test/lib/share/classes/jdk/test/lib/apps/LingeredApp.java	Wed Jun 17 21:43:26 2015 +0000
+++ b/test/lib/share/classes/jdk/test/lib/apps/LingeredApp.java	Tue Jun 23 12:30:57 2015 +0300
@@ -287,7 +287,7 @@
             }
         }
         else{
-            // Lets user manage LingerApp options
+            // Lets user manage LingeredApp options
             cmd.addAll(vmArguments);
         }
 
@@ -321,6 +321,20 @@
     }
 
     /**
+     * Delete lock file that signals app to terminate, then
+     * wait until app is actually terminated.
+     * @throws IOException
+     */
+    public void stopApp() throws IOException {
+        deleteLock();
+        waitAppTerminate();
+        int exitcode = appProcess.exitValue();
+        if (exitcode != 0) {
+            throw new IOException("LingeredApp terminated with non-zero exit code " + exitcode);
+        }
+    }
+
+    /**
      *  High level interface for test writers
      */
     /**
@@ -351,17 +365,11 @@
         return startApp(null);
     }
 
-    /**
-     * Delete lock file that signal app to terminate, then
-     * waits until app is actually terminated.
-     * @throws IOException
-     */
-    public void stopApp() throws IOException {
-        deleteLock();
-        waitAppTerminate();
-        int exitcode = appProcess.exitValue();
-        if (exitcode != 0) {
-            throw new IOException("LingeredApp terminated with non-zero exit code " + exitcode);
+    public static void stopApp(LingeredApp app) throws IOException {
+        if (app != null) {
+            // LingeredApp can throw an exception during the intialization,
+            // make sure we don't have cascade NPE
+            app.stopApp();
         }
     }