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

java.io.PipedOutputStream.write(b) method does not work with unconnected streams

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description



      Name: saf@russia Date: 09/09/96


      This bug was found by St.Petersburg Java SQE team (by Stanislav Avzan).

      The java.io.PipedOutputStream.write(b) method does not work according to
      the Java language specification if stream is unconnected.

      The Java Language specification
      (Version 1.0 - August 1, 1996)
      says the following (please see item 22.17.4):

      "22.17.4 public void write(int b) throws IOException

      If a thread was reading data bytes from the connected piped input stream,
      but the thread is no longer alive, then an IOException is thrown.

      Implements the write method of OutputStream (p. 22.15.1)."

      So this method should not throw NullPointerException.
      But in fact when stream is unconnected it does.
       
      By the way, the behaviour expected in this case is not explicitly documented.

      This bug also affects write(b,off,len) method.
       
      Here is the minimized test demonstrating the bug:
          

      ----- test12.java ---------------------------------------
      import java.io.*;

      public class test12 {

         public static void main( String[] argv ) {
           PipedOutputStream os = new PipedOutputStream();
           try {
             os.write(1);
             System.out.println("No exceptions thrown");
           } catch(Throwable e) {
             // only IOException is allowed
             System.out.println("Exception <"+e+"> thrown");
           }
         }
      }

      ----- The output of the test: -------------------------

      $JAVA test12
      Exception <java.lang.NullPointerException> thrown

      -------------------------------------------------------

       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              zlisunw Zhenghua Li (Inactive)
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: