The jdk.jfr.FlightRecorderListener allows clients to listens to changes to JFR, such as when a new recording is started and stopped. For example, FlightRecorder.addListener(new FlightRecorderListener() { public void recordingStateChanged(Recording r) { System.out.println("Recording " + r.getName() + " " + r.getState()); } }); This works well, but if a user calls Recording::dump(path): Recording r = new Recording(); r.dump(Path.of("dump.jfr")); the JFR implementation piggybacks on the existing implementation and creates a temporary cloned recording in the dump method that is not visible to users. The temporary recording holds references to chunks in the disk repository while the dump takes places. This is so chunks are not removed by some other mechanism, for example maxAge and maxSize, while the dump happens. Problem is that a notification is sent for the internal/temporary recording and since there is no jdk.jfr.Recording object associated with it, it returns null. Fix is to not send a notification if it is an internal recording The problem is manifested as a NullPointerException in the code that is using FlightRecorder::addListener method.
|