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

EventStream::close should state that stream will be stopped

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P3
    • 15
    • 15
    • hotspot
    • jfr
    • b14

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: