Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8230767

FlightRecorderListener returns null recording

    Details

    • Type: Bug
    • Status: Open
    • Priority: P3
    • Resolution: Unresolved
    • Affects Version/s: 11, 14
    • Fix Version/s: 14
    • Component/s: hotspot
    • Subcomponent:
      jfr

      Description

      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.

        Attachments

          Activity

            People

            • Assignee:
              egahlin Erik Gahlin
              Reporter:
              egahlin Erik Gahlin
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: