8266014: Regression brought by optimization done with JDK-4926314

Reviewed-by: alanb, naoto
This commit is contained in:
Brian Burkhalter 2021-04-29 15:35:14 +00:00
parent 6bb71d9e25
commit 2a03739530
2 changed files with 18 additions and 4 deletions

View file

@ -188,9 +188,7 @@ public abstract class Reader implements Readable, Closeable {
if (target.hasArray()) {
char[] cbuf = target.array();
int pos = target.position();
int rem = target.limit() - pos;
if (rem <= 0)
return -1;
int rem = Math.max(target.limit() - pos, 0);
int off = target.arrayOffset() + pos;
nread = this.read(cbuf, off, rem);
if (nread > 0)