8081576: serviceability/sa tests fail due to LingeredApp process fails to start

Provide a API to corrctly terminate LingeredApp

Reviewed-by: sspitsyn
This commit is contained in:
Dmitry Samersoff 2015-06-23 12:30:57 +03:00
parent 8993ac36f0
commit c62e4b8ee3

@ -287,7 +287,7 @@ public class LingeredApp {
}
}
else{
// Lets user manage LingerApp options
// Lets user manage LingeredApp options
cmd.addAll(vmArguments);
}
@ -320,6 +320,20 @@ public class LingeredApp {
gb.start();
}
/**
* 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 @@ public class LingeredApp {
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();
}
}