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

(ch spec) Clarify Channels.newChannel(InputStream) spec

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 22
    • core-libs
    • None
    • behavioral
    • minimal
    • Addition of verbiage only; no change in behavior.
    • Java API
    • SE

      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

            bpb Brian Burkhalter
            earmstrosunw Eric Armstrong (Inactive)
            Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: