Cornelius Riemenschneider opened SPR-13858 and commented
The read(byte[] b, int off, int len) method of FastByteArrayOutputStream$FastByteArrayInputStream returns 0 instead of -1 in the condition of this.currentBuffer == null.
The correct return value would be -1, as the read() method already does.
This breaks for example StreamUtils.copy(), which never leaves the loop.
The issue is fixed by replacing
if (this.currentBuffer == null) {
// this stream doesn't have any data in it
return 0;
}
with
if (this.currentBuffer == null) {
// this stream doesn't have any data in it
return -1;
}
Affects: 4.2.4
Referenced from: commits 5d4547d, 8516de6