PipedOutputStream write(0, 0) successful after close()

XMLWordPrintable

    • Type: CSR
    • Resolution: Approved
    • Priority: P5
    • 26
    • Component/s: core-libs
    • None
    • behavioral
    • minimal
    • Little risk as this only changes the specification to match longstanding behavior.
    • Java API
    • SE

      Summary

      Change specification of java.io.PipedOutputStream.write(byte[],int,int) to indicate that an IOException is thrown when the stream is closed and an attempt is made to write a positive number of bytes.

      Problem

      The specification of java.io.PipedOutputStream.write(byte[],int,int) indicates that an IOException is always thrown if the stream is closed but this is not the case if the number of bytes to be written is zero.

      Solution

      Revise the specification to match longstanding behavior.

      Specification

      --- a/src/java.base/share/classes/java/io/PipedOutputStream.java
      +++ b/src/java.base/share/classes/java/io/PipedOutputStream.java
      @@ -129,16 +129,17 @@ public void write(int b)  throws IOException {
           /**
            * Writes {@code len} bytes from the specified byte array
            * starting at offset {@code off} to this piped output stream.
      -     * This method blocks until all the bytes are written to the output
      -     * stream.
      +     * If {@code len} is not zero, this method blocks until all the
      +     * bytes are written to the output stream.
            *
            * @param   b     {@inheritDoc}
            * @param   off   {@inheritDoc}
            * @param   len   {@inheritDoc}
      +     * @throws  IndexOutOfBoundsException {@inheritDoc}
            * @throws  IOException if the pipe is <a href=#BROKEN> broken</a>,
            *          {@link #connect(java.io.PipedInputStream) unconnected},
      -     *          closed, or if an I/O error occurs.
      -     * @throws  IndexOutOfBoundsException {@inheritDoc}
      +     *          closed and {@code len} is greater than zero,
      +     *          or if an I/O error occurs.
            */
           @Override
           public void write(byte[] b, int off, int len) throws IOException {
      

            Assignee:
            Brian Burkhalter
            Reporter:
            Webbug Group
            Jaikiran Pai, Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: