-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.0.2
-
sparc
-
solaris_2.5
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
-------------------------------------------------------
- duplicates
-
JDK-1267037 java.io.Piped*Stream specification does not describe unconnected streams
-
- Closed
-
- relates to
-
JDK-4028322 java.io.PipedInputStream doesn't reliably support multiple writers
-
- Closed
-