JDK-4404854 : (cs) jdk regression: InputStreamReader.skip(int) raises unexpected exception
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 2001-01-16
  • Updated: 2001-10-11
  • Resolved: 2001-10-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 beta3Fixed
Related Reports
Relates :  
Description

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

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: merlin-beta3 INTEGRATED IN: merlin-beta3 VERIFIED IN: merlin-beta3
14-06-2004

EVALUATION That this test was seeing an error thrown was fixed by 4503732. Note that the test itself is incorrect; it's expecting an IOException to be thrown for invalid UTF-8 data, which is not guaranteed by the specification (see 4403272). -- ###@###.### 2001/9/28
09-09-0194