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
======================================================================
The description field as copied from bug report 1266152 follows:
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
======================================================================
- duplicates
-
JDK-1266152 The java.io.PipedInputStream.connect method works wrong with null parameter
- Closed