# HG changeset patch # User amurillo # Date 1472764144 25200 # Node ID 43f23b5c9fed73957f0a00eaf7611dc7bdfbbe05 # Parent 70a4f131d226b4a1dafb298add65afd245420d39# Parent 41e6677cdff5c76d0647a56b8470f3e969f32938 Merge diff -r 70a4f131d226 -r 43f23b5c9fed jdk/test/sun/tools/jhsdb/BasicLauncherTest.java --- a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java Thu Sep 01 08:39:27 2016 -0700 +++ b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java Thu Sep 01 14:09:04 2016 -0700 @@ -35,6 +35,7 @@ import java.io.BufferedReader; import java.io.IOException; +import java.io.OutputStream; import java.io.InputStreamReader; import java.io.File; import java.util.ArrayList; @@ -84,15 +85,24 @@ ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand()); processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT); Process toolProcess = processBuilder.start(); - toolProcess.getOutputStream().write("quit\n".getBytes()); - toolProcess.getOutputStream().close(); + + try (OutputStream out = toolProcess.getOutputStream()) { + out.write("universe\n".getBytes()); + out.write("quit\n".getBytes()); + } // By default child process output stream redirected to pipe, so we are reading it in foreground. - BufferedReader reader = new BufferedReader(new InputStreamReader(toolProcess.getInputStream())); + Exception unexpected = null; + try (BufferedReader reader = new BufferedReader(new InputStreamReader(toolProcess.getInputStream()))) { + String line; + while ((line = reader.readLine()) != null) { + line = line.trim(); + System.out.println(line); - String line; - while ((line = reader.readLine()) != null) { - System.out.println(line.trim()); + if (line.contains("unknown subtype of CollectedHeap")) { + unexpected = new RuntimeException("CollectedHeap type should be known."); + } + } } toolProcess.waitFor(); @@ -100,6 +110,10 @@ if (toolProcess.exitValue() != 0) { throw new RuntimeException("FAILED CLHSDB terminated with non-zero exit code " + toolProcess.exitValue()); } + + if (unexpected != null) { + throw unexpected; + } } catch (Exception ex) { throw new RuntimeException("Test ERROR " + ex, ex); } finally {