Summary
Add verbiage to java.nio.channels.Channels.newChannel(InputStream)
to make it explicit that reading from the channel might block as the wrapped stream might block.
Problem
The specification of Channels.newChannel(InputStream)
does not make it explicit that the read
method of the returned ReadableByteChannel
might block.
Solution
Add a sentence highlighting the blocking behavior.
Specification
--- a/src/java.base/share/classes/java/nio/channels/Channels.java
+++ b/src/java.base/share/classes/java/nio/channels/Channels.java
@@ -260,8 +260,10 @@ public final class Channels {
* Constructs a channel that reads bytes from the given stream.
*
* <p> The resulting channel will not be buffered; it will simply redirect
- * its I/O operations to the given stream. Closing the channel will in
- * turn cause the stream to be closed. </p>
+ * its I/O operations to the given stream. Reading from the resulting
+ * channel will read from the input stream and thus block until input is
+ * available or end of file is reached. Closing the channel will in turn
+ * cause the stream to be closed. </p>
*
* @param in
* The stream from which bytes are to be read
- csr of
-
JDK-4800398 (ch spec) Clarify Channels.newChannel(InputStream) spec
-
- Resolved
-