EventStream::close should state that stream will be stopped

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P3
    • 15
    • Affects Version/s: 15
    • Component/s: hotspot
    • jfr
    • b14

      Users have been surprised that the underlying stream is stopped when the EventStream is closed. This could be because example code from a synchronous stream was copied, i.e.

      try (RecordingStream r = new RecordingStream()) {
         r.onEvent(...);
         r.start();
      }

      and made asynchronous by changing r.start() to r.startAsync(), whereby they don't get any events since the stream is closed immediately when the current thread exits the try-with-resources block.

      It may make sense to call this out in the javadoc and state in the specification of the EventStream::close method that the stream will be stopped when closed.

      Perhaps also add example code where an async stream is started so users can better understand that use case.

            Assignee:
            Erik Gahlin
            Reporter:
            Erik Gahlin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: