Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.
/ jdk13u-dev Public archive

Commit

Permalink
8230767: FlightRecorderListener returns null recording
Browse files Browse the repository at this point in the history
Backport-of: b3d2b3b
  • Loading branch information
Ekaterina Vergizova authored and Yuri Nesterenko committed Nov 26, 2020
1 parent 85a31ac commit 91b19c9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,10 @@ private void notifyIfStateChanged(RecordingState newState, RecordingState oldSta
}
for (FlightRecorderListener cl : PlatformRecorder.getListeners()) {
try {
cl.recordingStateChanged(getRecording());
// Skip internal recordings
if (recording != null) {
cl.recordingStateChanged(recording);
}
} catch (RuntimeException re) {
Logger.log(JFR, WARN, "Error notifying recorder listener:" + re.getMessage());
}
Expand Down
37 changes: 37 additions & 0 deletions test/jdk/jdk/jfr/api/recorder/TestRecorderListenerWithDump.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package jdk.jfr.api.recorder;

import java.nio.file.Paths;
import java.util.concurrent.atomic.AtomicBoolean;

import jdk.jfr.FlightRecorder;
import jdk.jfr.FlightRecorderListener;
import jdk.jfr.Recording;
/**
* @test TestRecorderListenerWithDump
*
* @key jfr
* @requires vm.hasJFR
* @run main/othervm jdk.jfr.api.recorder.TestRecorderListenerWithDump
*/
public class TestRecorderListenerWithDump {

public static void main(String... args) throws Exception {
AtomicBoolean nullRecording = new AtomicBoolean();
FlightRecorder.addListener(new FlightRecorderListener() {
public void recordingStateChanged(Recording r) {
if (r == null) {
nullRecording.set(true);
} else {
System.out.println("Recording " + r.getName() + " " + r.getState());
}
}
});
try (Recording r = new Recording()) {
r.start();
r.dump(Paths.get("dump.jfr"));
}
if (nullRecording.get()) {
throw new Exception("FlightRecorderListener returned null recording");
}
}
}

1 comment on commit 91b19c9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.