Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4404854

(cs) jdk regression: InputStreamReader.skip(int) raises unexpected exception

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      beta3
    • CPU:
      sparc
    • OS:
      solaris_2.6
    • Verification:
      Verified

      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

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mr Mark Reinhold
              Reporter:
              avusunw Avu Avu (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: