8081576: serviceability/sa tests fail due to LingeredApp process fails to start
Summary: Provide a API to corrctly terminate LingeredApp
Reviewed-by: sspitsyn
--- 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();
}
}