FastByteArrayInputStream returns correct count from read(byte[])

Issue: SPR-14209
(cherry picked from commit 9bf5a5c)
This commit is contained in:
Juergen Hoeller
2016-04-26 17:00:59 +02:00
parent 9fa061431c
commit b9fa67e0e6
2 changed files with 56 additions and 38 deletions

View File

@@ -53,7 +53,7 @@ public class FastByteArrayOutputStream extends OutputStream {
// The size, in bytes, to use when allocating the first byte[]
private final int initialBlockSize;
// The size, in bytes, to use when allocating the next next byte[]
// The size, in bytes, to use when allocating the next byte[]
private int nextBlockSize = 0;
// The number of bytes in previous buffers.
@@ -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()) {