-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta3
-
sparc
-
solaris_2.6
-
Verified
Name: auR10023 Date: 01/16/2001
Method java.io.InputStreamReader.skip(int) raises java.lang.Error instead of
IOException when ByteArrayInputStream is empty.
In jdk1.3 this method throws IOException in this case.
Here is the test demonstrating the bug:
------------------- t.java -------------
import java.io.*;
public class t{
public static void main(String [] args) {
byte[] bytes = { (byte)128 };
char[] readChars = new char[10];
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
InputStreamReader isr = null;
try {
isr = new InputStreamReader(bais, "UTF8");
} catch(UnsupportedEncodingException e){
System.out.println("Unexpected exception");
return;
}
try {
isr.skip(1);
} catch (IOException ioe) {
System.out.println("IOException was thrown as expected");
return;
}
System.out.println("read should have thrown IOException");
}
}
----------- output from the test: --------------------
#> java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b46)
Java HotSpot(TM) Client VM (build 1.4beta-B45, mixed mode)
#> java t
Exception in thread "main" java.lang.Error
at java.io.InputStreamReader$CharsetFiller.fill(InputStreamReader.java:353)
at java.io.InputStreamReader.read(InputStreamReader.java:478)
at java.io.Reader.skip(Reader.java:148)
at t.main(t.java:17)
#> java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, interpreted mode)
#> java t
IOException was thrown as expected
======================================================================
- relates to
-
JDK-4503732 (cs) Charset API redesign
- Resolved