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

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

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Unresolved
    • Icon: P5 P5
    • 26
    • 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
      @@ -135,10 +135,11 @@ public void write(int b)  throws IOException {
            * @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 {

            bpb Brian Burkhalter
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated: