Skip to content

Commit 2bd138b

Browse files
cost0muchVictor Rudometov
authored andcommitted
8316193: jdk/jfr/event/oldobject/TestListenerLeak.java java.lang.Exception: Could not find leak
Backport-of: f6be922952642f40dcf0d27b7896c9a6acdd6378
1 parent eaf9556 commit 2bd138b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

test/jdk/jdk/jfr/event/oldobject/TestListenerLeak.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -71,15 +71,17 @@ public void onListen() {
7171

7272
public static void main(String[] args) throws Exception {
7373
WhiteBox.setWriteAllObjectSamples(true);
74-
75-
try (Recording r = new Recording()) {
76-
r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity");
77-
r.start();
78-
listenerLeak();
79-
r.stop();
80-
List<RecordedEvent> events = Events.fromRecording(r);
81-
if (OldObjects.countMatchingEvents(events, Stuff[].class, null, null, -1, "listenerLeak") == 0) {
82-
throw new Exception("Could not find leak with " + Stuff[].class);
74+
while (true) {
75+
try (Recording r = new Recording()) {
76+
r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity");
77+
r.start();
78+
listenerLeak();
79+
r.stop();
80+
List<RecordedEvent> events = Events.fromRecording(r);
81+
if (OldObjects.countMatchingEvents(events, Stuff[].class, null, null, -1, "listenerLeak") != 0) {
82+
return; // Success
83+
}
84+
System.out.println("Could not find leak with " + Stuff[].class + ". Retrying.");
8385
}
8486
}
8587
}

0 commit comments

Comments
 (0)