Skip to content

Commit dfa04f4

Browse files
committed
8370653: Fix race in CompressedClassSpaceSizeInJmapHeap.java
Reviewed-by: phh, wkemper, ysr
1 parent a926c21 commit dfa04f4

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

test/hotspot/jtreg/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import java.util.List;
4747

4848
public class CompressedClassSpaceSizeInJmapHeap {
49+
4950
// Note that on some platforms it may require root privileges to run this test.
5051
public static void main(String[] args) throws Exception {
5152
SATestUtils.skipIfCannotAttach(); // throws SkippedException if attach not expected to work.
@@ -67,21 +68,25 @@ public static void main(String[] args) throws Exception {
6768
File err = new File("CompressedClassSpaceSizeInJmapHeap.stderr.txt");
6869
pb.redirectError(err);
6970

70-
run(pb);
71-
71+
// If we attempt to attach to LingeredApp before it has initialized, the heap dump request will fail, so we allow 3 tries
72+
int allowedTries = 3;
73+
int exitValue;
74+
do {
75+
exitValue = run(pb);
76+
} while ((exitValue != 0) && (allowedTries-- > 0));
77+
if (exitValue != 0) {
78+
throw new Exception("jmap -heap exited with error code: " + exitValue);
79+
}
7280
OutputAnalyzer output = new OutputAnalyzer(read(out));
7381
output.shouldContain("CompressedClassSpaceSize = 50331648 (48.0MB)");
7482
out.delete();
7583

7684
LingeredApp.stopApp(theApp);
7785
}
7886

79-
private static void run(ProcessBuilder pb) throws Exception {
87+
private static int run(ProcessBuilder pb) throws Exception {
8088
OutputAnalyzer output = ProcessTools.executeProcess(pb);
81-
int exitValue = output.getExitValue();
82-
if (exitValue != 0) {
83-
throw new Exception("jmap -heap exited with error code: " + exitValue);
84-
}
89+
return output.getExitValue();
8590
}
8691

8792
private static String read(File f) throws Exception {

0 commit comments

Comments
 (0)