8262157: LingeredApp.startAppExactJvmOpts does not print app output when launching fails

Reviewed-by: iklam, cjplummer
This commit is contained in:
Yumin Qi
2021-02-24 00:31:57 +00:00
parent c769388d0f
commit 3e13b66e3f

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -88,6 +88,7 @@ public class LingeredApp {
private ByteArrayOutputStream stdoutBuffer;
private Thread outPumperThread;
private Thread errPumperThread;
private boolean finishAppCalled = false;
protected Process appProcess;
protected OutputBuffer output;
@@ -367,6 +368,11 @@ public class LingeredApp {
private void finishApp() {
if (appProcess != null) {
if (finishAppCalled) {
return;
} else {
finishAppCalled = true;
}
OutputBuffer output = getOutput();
String msg =
" LingeredApp stdout: [" + output.getStdout() + "];\n" +
@@ -416,6 +422,8 @@ public class LingeredApp {
theApp.runAppExactJvmOpts(jvmOpts);
theApp.waitAppReady();
} catch (Exception ex) {
System.out.println("LingeredApp failed to start: " + ex);
theApp.finishApp();
theApp.deleteLock();
throw ex;
}
@@ -441,14 +449,7 @@ public class LingeredApp {
*/
public static LingeredApp startApp(String... additionalJvmOpts) throws IOException {
LingeredApp a = new LingeredApp();
try {
startApp(a, additionalJvmOpts);
} catch (Exception ex) {
System.out.println("LingeredApp failed to start: " + ex);
a.finishApp();
throw ex;
}
startApp(a, additionalJvmOpts);
return a;
}