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

The java.io.PipedInputStream.connect method works wrong with null parameter

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P1 P1
    • None
    • 1.0.2
    • core-libs
    • sparc
    • solaris_2.5



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


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

      The java.io.PipedInputStream.connect method does not work with null
      parameter according to the Java language specification.

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

      "22.5.3 public void connect(PipedOutputStream src) throws IOException

      The connect method causes this piped input stream to be connected to
      the piped output stream src. If this object is already connected to some
      other piped output stream, an IOException is thrown.

      If src is an unconnected piped output stream and snk is an unconnected
      piped input stream, they may be connected by either the call:

      snk.connect(src)

      or the call:

      src.connect(snk)

      The two calls have the same effect. "

      So this method should not throw NullPointerException
      if passed null as argument.
      But in fact it does.
       
      Here is the minimized test demonstrating the bug:
          

      ----- test1.java ---------------------------------------
      import java.io.*;

      public class test1 {

         public static void main( String[] argv ) {
           try {
             PipedInputStream is = new PipedInputStream();
             is.connect(null);
             System.out.println("Test failed: IOException expected");

           } catch(IOException e) {
             System.out.println("Test passed: IOException thrown");
           } catch(Throwable e) {
             System.out.println("Test failed: unexpected <"+e+"> thrown");
           }
         }
      }

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

      $JAVA test1
      Test failed: unexpected <java.lang.NullPointerException> thrown

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


      Workaround:
      None
      ======================================================================

            djbrown David Brown (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: