Skip to content

Commit 5906588

Browse files
committed
8316562: serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java times out after JDK-8314829
Backport-of: 54028e779bb076a5ab1c03baa8ab89587252af4a
1 parent 5faa0df commit 5906588

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
import java.io.File;
2626
import java.io.FileNotFoundException;
2727
import java.io.FileReader;
28+
import java.io.InputStreamReader;
2829
import java.io.IOException;
2930
import java.io.Reader;
3031
import java.nio.CharBuffer;
3132
import java.util.Arrays;
32-
import java.util.Scanner;
3333

3434
import jdk.test.lib.Asserts;
3535
import jdk.test.lib.JDKToolLauncher;
@@ -82,15 +82,22 @@ private static void testHProfFileFormat(String vmArgs, long heapSize,
8282
procBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
8383
Process largeHeapProc = procBuilder.start();
8484

85-
try (Scanner largeHeapScanner = new Scanner(
86-
largeHeapProc.getInputStream());) {
85+
try (BufferedReader r = new BufferedReader(
86+
new InputStreamReader(largeHeapProc.getInputStream()))) {
8787
String pidstring = null;
88-
if (!largeHeapScanner.hasNext()) {
89-
throw new RuntimeException ("Test failed: could not open largeHeapScanner.");
88+
while ((pidstring = r.readLine()) != null) {
89+
// The output might contain different VM output, skip it while searching PID line.
90+
if (pidstring.matches("PID\\[[0-9].*\\]")) {
91+
System.out.println("Found: " + pidstring);
92+
break;
93+
} else {
94+
System.out.println("Ignoring: " + pidstring);
95+
}
9096
}
91-
while ((pidstring = largeHeapScanner.findInLine("PID\\[[0-9].*\\]")) == null) {
92-
Thread.sleep(500);
97+
if (pidstring == null) {
98+
throw new RuntimeException("Not able to find string matching PID.");
9399
}
100+
94101
int pid = Integer.parseInt(pidstring.substring(4,
95102
pidstring.length() - 1));
96103
System.out.println("Extracted pid: " + pid);

0 commit comments

Comments
 (0)