FastByteArrayInputStream returns correct count from read(byte[])

Issue: SPR-14209
This commit is contained in:
Juergen Hoeller
2016-04-26 17:00:59 +02:00
parent 9ec0873604
commit 9bf5a5cbcb
2 changed files with 54 additions and 36 deletions

View File

@@ -421,7 +421,8 @@ public class FastByteArrayOutputStream extends OutputStream {
System.arraycopy(this.currentBuffer, this.nextIndexInCurrentBuffer, b, off, bytesToCopy);
this.totalBytesRead += bytesToCopy;
this.nextIndexInCurrentBuffer += bytesToCopy;
return (bytesToCopy + read(b, off + bytesToCopy, len - bytesToCopy));
int remaining = read(b, off + bytesToCopy, len - bytesToCopy);
return bytesToCopy + Math.max(remaining, 0);
}
else {
if (this.buffersIterator.hasNext()) {