changeset 48142:39afb6894e3a

8190911: tools/jdeps/MultiReleaseJar.java failed with java.lang.IllegalThreadStateException Reviewed-by: bpb
author mchung
date Mon, 27 Nov 2017 14:41:59 -0800
parents cece8b7adf10
children e5df7ccc4b73
files test/langtools/tools/jdeps/MultiReleaseJar.java
diffstat 1 files changed, 19 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/test/langtools/tools/jdeps/MultiReleaseJar.java	Mon Nov 27 22:22:03 2017 +0100
+++ b/test/langtools/tools/jdeps/MultiReleaseJar.java	Mon Nov 27 14:41:59 2017 -0800
@@ -240,17 +240,26 @@
         cmds[0] = cmdPath.resolve(cmds[0]).toString();
         ProcessBuilder pb = new ProcessBuilder(cmds);
         pb.directory(mrjar.toFile());
-        Process p = pb.start();
-        p.waitFor(10, TimeUnit.SECONDS);
-        String out;
-        try (InputStream is = p.getInputStream()) {
-            out = new String(is.readAllBytes());
+        Process p = null;
+        try {
+            p = pb.start();
+            p.waitFor();
+
+            String out;
+            try (InputStream is = p.getInputStream()) {
+                out = new String(is.readAllBytes());
+            }
+            String err;
+            try (InputStream is = p.getErrorStream()) {
+                err = new String(is.readAllBytes());
+            }
+            return new Result(cmd, p.exitValue(), out, err);
+        } catch (Throwable t) {
+            if (p != null) {
+                p.destroyForcibly().waitFor();
+            }
+            throw t;
         }
-        String err;
-        try (InputStream is = p.getErrorStream()) {
-            err = new String(is.readAllBytes());
-        }
-        return new Result(cmd, p.exitValue(), out, err);
     }
 
     void checkResult(Result r) throws Exception {