Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2017099 | 1.2.0 | Alan Sommerer | P3 | Resolved | Fixed | 1.2beta3 |
Name: joT67522 Date: 09/24/97
According to the docs on this routine, "If the first argument is
null, up to len bytes are read and discarded." However, it does
not do this. Instead, it throws an exception.
/* Example code */
import java.io.*;
public class Test
{
public static void main(String[] args) throws IOException
{
byte[] buf = new byte[16];
System.in.read(null, 0, 5); // Read and discard first 5 bytes
System.in.read(buf, 0, 11); // Place next 11 bytes in buf
System.out.write(buf, 0, 5); // Write out the first 5 bytes in buf
}
}
/* Example output *
If there was no bug, we would see this:
C:\> java Test <- we run the progran
0123456789abcdef <- we enter this
56789 <- and the program writes this
However, there is a bug, and instead we see this:
C:\> java Test
0123456789abcdef
java.lang.NullPointerException
at java.io.BufferedInputStream.read(BufferedInputStream.java:209)
at Test.main(Test.java:9)
\* End of example */
company - SCSU , email - ###@###.###
======================================================================
- backported by
-
JDK-2017099 InputStream.read(byte[], int, int) does not work as documented if passed null
-
- Resolved
-