8230767: FlightRecorderListener returns null recording
Reviewed-by: mseledtsov, mgronlun
This commit is contained in:
parent
43368f8f9f
commit
b3d2b3ba5f
@ -484,7 +484,10 @@ public final class PlatformRecording implements AutoCloseable {
|
||||
}
|
||||
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());
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user