changeset 60057:87651cb03ebc

8238710: LingeredApp doesn't log stdout/stderr if exits with non-zero code Reviewed-by: cjplummer, sspitsyn
author amenkov
date Thu, 13 Feb 2020 13:43:09 -0800
parents 6bcfcb7fe83b
children c389ca962c0d f9a8545546ae 4a51efe43d9a 1f0d22fac01e c4112a51f542 f16f6d00cecc 175735635b5f 9ecc33cc755c 61aebf6881a2 7e6165c9c606
files test/lib/jdk/test/lib/apps/LingeredApp.java
diffstat 1 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/test/lib/jdk/test/lib/apps/LingeredApp.java	Thu Feb 13 16:01:46 2020 -0500
+++ b/test/lib/jdk/test/lib/apps/LingeredApp.java	Thu Feb 13 13:43:09 2020 -0800
@@ -357,13 +357,15 @@
     }
 
     private void finishApp() {
-        OutputBuffer output = getOutput();
-        String msg =
-            " LingeredApp stdout: [" + output.getStdout() + "];\n" +
-            " LingeredApp stderr: [" + output.getStderr() + "]\n" +
-            " LingeredApp exitValue = " + appProcess.exitValue();
+        if (appProcess != null) {
+            OutputBuffer output = getOutput();
+            String msg =
+                    " LingeredApp stdout: [" + output.getStdout() + "];\n" +
+                    " LingeredApp stderr: [" + output.getStderr() + "]\n" +
+                    " LingeredApp exitValue = " + appProcess.exitValue();
 
-        System.err.println(msg);
+            System.err.println(msg);
+        }
     }
 
     /**
@@ -377,12 +379,14 @@
         // an exception before the LA actually starts
         if (appProcess != null) {
             waitAppTerminate();
+
+            finishApp();
+
             int exitcode = appProcess.exitValue();
             if (exitcode != 0) {
                 throw new IOException("LingeredApp terminated with non-zero exit code " + exitcode);
             }
         }
-        finishApp();
     }
 
     /**