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

(ch) Add implNote about minBufferCap to main variant of Channels.newWriter

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P4
    • 22
    • core-libs
    • None
    • behavioral
    • minimal
    • There should be no observable change in behavior.
    • Java API
    • SE

    Description

      Summary

      Modify the specification of the minBufferCap parameter of the principal, three-parameter variant of java.nio.channels.Channels.newWriter to indicate that it is ignored.

      Problem

      The implementation of this variant of Channels.newWriter allowed for problematic behavior and required duplicate implementations for OutputStream and WritableByteChannel.

      Solution

      Remove WritableByteChannel support in StreamEncoder and instead use an OutputStream that wraps a WritableByteChannel.

      Specification

      --- a/src/java.base/share/classes/java/nio/channels/Channels.java
      +++ b/src/java.base/share/classes/java/nio/channels/Channels.java
      @@ -521,20 +521,24 @@
            * channel; if the channel is in non-blocking mode when bytes are to be
            * written then an {@link IllegalBlockingModeException} will be thrown.
            * The resulting stream will not otherwise be buffered.  Closing the stream
            * will in turn cause the channel to be closed.  </p>
            *
      +     * @implNote
      +     * The value of {@code minBufferCap} is ignored.
      +     *
            * @param  ch
            *         The channel to which bytes will be written
            *
            * @param  enc
            *         The charset encoder to be used
            *
            * @param  minBufferCap
            *         The minimum capacity of the internal byte buffer,
            *         or {@code -1} if an implementation-dependent
      -     *         default capacity is to be used
      +     *         default capacity is to be used. The value of
      +     *         {@code minBufferCap} may be ignored
            *
            * @return  A new writer
            */
           public static Writer newWriter(WritableByteChannel ch,
                                          CharsetEncoder enc,

      Attachments

        Issue Links

          Activity

            People

              bpb Brian Burkhalter
              bpb Brian Burkhalter
              Alan Bateman, Roger Riggs
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: