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

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

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      IOException should thrown– if the pipe is broken, unconnected, closed, or if an I/O error occurs.
      But when length is 0, this check passed.


      ---------- BEGIN SOURCE ----------
      import java.io.IOException;
      import java.io.PipedInputStream;
      import java.io.PipedOutputStream;

      public class ClosedWrite {
          public static void main(String[] argv) throws Exception {
              PipedOutputStream os = new PipedOutputStream();
              PipedInputStream is = new PipedInputStream();
              os.connect(is);
              os.close();
              
              // Test zero-length write on closed stream
              try {
                  byte[] data = {1, 2, 3};
                  os.write(data, 0, 0);
                  throw new RuntimeException("No IOException upon zero-length write on closed Stream");
              } catch(IOException e) {
                  System.err.println("Test passed: IOException thrown for zero-length write");
              }
          }
      }
      ---------- END SOURCE ----------

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

              Created:
              Updated: