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

java.io.InputStreamReader.read(buf, off, len) broken for non-zero offsets

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.4.0
    • 1.4.0
    • core-libs
    • beta
    • generic
    • generic, solaris_7
    • Verified

      % cat Bug.java

      import java.io.*;

      public class Bug {

          public static void main(String[] args) throws Exception {
      InputStream is
      = new ByteArrayInputStream("foo bar".getBytes("US-ASCII"));
      InputStreamReader isr = new InputStreamReader(is, "US-ASCII");
      char[] cbuf = new char[100];
      int n;
      System.out.println(n = isr.read(cbuf, 0, 3));
      System.out.println(isr.read(cbuf, n, cbuf.length - n));
          }

      }

      % /w/int/build/linux-i386/bin/javac Bug.java
      % /w/int/build/linux-i386/bin/java Bug
      3
      Exception in thread "main" java.lang.IllegalArgumentException
              at java.nio.Buffer.limit(Buffer.java:226)
              at java.nio.Buffer.<init>(Buffer.java:153)
              at java.nio.CharBuffer.<init>(CharBuffer.java:230)
              at java.nio.HeapCharBuffer.<init>(HeapCharBuffer.java:29)
              at java.nio.CharBuffer.wrap(CharBuffer.java:297)
              at java.io.InputStreamReader$CharsetFiller.fill(InputStreamReader.java:355)
              at java.io.InputStreamReader.read(InputStreamReader.java:478)
              at Bug.main(Bug.java:13)
      %

      -- mr@eng 2000/12/19

            mr Mark Reinhold
            mr Mark Reinhold
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: