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 ----------
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 ----------