Index: modules/luni/src/main/java/java/io/InputStreamReader.java =================================================================== --- modules/luni/src/main/java/java/io/InputStreamReader.java (revision 382396) +++ modules/luni/src/main/java/java/io/InputStreamReader.java (working copy) @@ -175,13 +175,8 @@ public int read() throws IOException { synchronized (lock) { if (isOpen()) { - if (chars.limit() == chars.position()) { - fillBuf(); - } - if (chars.limit() == 0) { - return -1; - } - return chars.get(); + char buf[] = new char[1]; + return read(buf, 0, 1) != -1 ? buf[0] : -1; } throw new IOException("InputStreamReader is closed."); //$NON-NLS-1$ } @@ -273,8 +268,18 @@ return; } bytes.limit(read); - boolean endOfInput = read < BUFFER_SIZE; + boolean endOfInput = in.available() == 0; CoderResult result = decoder.decode(bytes, chars, endOfInput); + while (result.isUnderflow() && !endOfInput) { + if(bytes.position()+bytes.arrayOffset() >= bytes.capacity()) + break; + read = in.read(bytes.array(), bytes.position()+bytes.arrayOffset(), 1); + bytes.limit(bytes.limit()+read); + if (read == -1) { + endOfInput = true; + } + result = decoder.decode(bytes, chars, endOfInput); + } if (result.isError()) { throw new IOException(result.toString()); }