-
Enhancement
-
Resolution: Fixed
-
P3
-
15
-
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.
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.
- csr for
-
JDK-8240311 EventStream::close should state that stream will be stopped
-
- Closed
-