Skip to content

Commit 3e13b66

Browse files
committed
8262157: LingeredApp.startAppExactJvmOpts does not print app output when launching fails
Reviewed-by: iklam, cjplummer
1 parent c769388 commit 3e13b66

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

test/lib/jdk/test/lib/apps/LingeredApp.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -88,6 +88,7 @@ public class LingeredApp {
8888
private ByteArrayOutputStream stdoutBuffer;
8989
private Thread outPumperThread;
9090
private Thread errPumperThread;
91+
private boolean finishAppCalled = false;
9192

9293
protected Process appProcess;
9394
protected OutputBuffer output;
@@ -367,6 +368,11 @@ public void runAppExactJvmOpts(String[] vmOpts)
367368

368369
private void finishApp() {
369370
if (appProcess != null) {
371+
if (finishAppCalled) {
372+
return;
373+
} else {
374+
finishAppCalled = true;
375+
}
370376
OutputBuffer output = getOutput();
371377
String msg =
372378
" LingeredApp stdout: [" + output.getStdout() + "];\n" +
@@ -416,6 +422,8 @@ public static void startAppExactJvmOpts(LingeredApp theApp, String... jvmOpts) t
416422
theApp.runAppExactJvmOpts(jvmOpts);
417423
theApp.waitAppReady();
418424
} catch (Exception ex) {
425+
System.out.println("LingeredApp failed to start: " + ex);
426+
theApp.finishApp();
419427
theApp.deleteLock();
420428
throw ex;
421429
}
@@ -441,14 +449,7 @@ public static void startApp(LingeredApp theApp, String... additionalJvmOpts) thr
441449
*/
442450
public static LingeredApp startApp(String... additionalJvmOpts) throws IOException {
443451
LingeredApp a = new LingeredApp();
444-
try {
445-
startApp(a, additionalJvmOpts);
446-
} catch (Exception ex) {
447-
System.out.println("LingeredApp failed to start: " + ex);
448-
a.finishApp();
449-
throw ex;
450-
}
451-
452+
startApp(a, additionalJvmOpts);
452453
return a;
453454
}
454455

0 commit comments

Comments
 (0)