Skip to content

Commit

Permalink
Backport f6be922952642f40dcf0d27b7896c9a6acdd6378
Browse files Browse the repository at this point in the history
  • Loading branch information
cost0much committed Aug 26, 2024
1 parent 3df1852 commit 3dd9121
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions test/jdk/jdk/jfr/event/oldobject/TestListenerLeak.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -74,15 +74,17 @@ public void onListen() {

public static void main(String[] args) throws Exception {
WhiteBox.setWriteAllObjectSamples(true);

try (Recording r = new Recording()) {
r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity");
r.start();
listenerLeak();
r.stop();
List<RecordedEvent> events = Events.fromRecording(r);
if (OldObjects.countMatchingEvents(events, Stuff[].class, null, null, -1, "listenerLeak") == 0) {
throw new Exception("Could not find leak with " + Stuff[].class);
while (true) {
try (Recording r = new Recording()) {
r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity");
r.start();
listenerLeak();
r.stop();
List<RecordedEvent> events = Events.fromRecording(r);
if (OldObjects.countMatchingEvents(events, Stuff[].class, null, null, -1, "listenerLeak") != 0) {
return; // Success
}
System.out.println("Could not find leak with " + Stuff[].class + ". Retrying.");
}
}
}
Expand Down

0 comments on commit 3dd9121

Please sign in to comment.