mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8287003: InputStreamReader::read() can return zero despite writing a char in the buffer
Reviewed-by: jpai, rriggs
This commit is contained in:
parent
63eb0b7e86
commit
6520843f86
2 changed files with 32 additions and 9 deletions
|
@ -215,7 +215,13 @@ public class StreamDecoder extends Reader {
|
|||
return n + 1;
|
||||
}
|
||||
|
||||
return n + implRead(cbuf, off, off + len);
|
||||
// Read remaining characters
|
||||
int nr = implRead(cbuf, off, off + len);
|
||||
|
||||
// At this point, n is either 1 if a leftover character was read,
|
||||
// or 0 if no leftover character was read. If n is 1 and nr is -1,
|
||||
// indicating EOF, then we don't return their sum as this loses data.
|
||||
return (nr < 0) ? (n == 1 ? 1 : nr) : (n + nr);
|
||||
}
|
||||
|
||||
public boolean ready() throws IOException {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue