Skip to content

Commit 8516de6

Browse files
committed
FastByteArrayInputStream consistently returns -1 when no data available
Issue: SPR-13858 (cherry picked from commit 5d4547d)
1 parent bcebc9d commit 8516de6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

spring-core/src/main/java/org/springframework/util/FastByteArrayOutputStream.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -361,7 +361,7 @@ public FastByteArrayInputStream(FastByteArrayOutputStream fastByteArrayOutputStr
361361
@Override
362362
public int read() {
363363
if (this.currentBuffer == null) {
364-
// this stream doesn't have any data in it
364+
// This stream doesn't have any data in it...
365365
return -1;
366366
}
367367
else {
@@ -412,8 +412,8 @@ else if (off < 0) {
412412
}
413413
else {
414414
if (this.currentBuffer == null) {
415-
// this stream doesn't have any data in it
416-
return 0;
415+
// This stream doesn't have any data in it...
416+
return -1;
417417
}
418418
else {
419419
if (this.nextIndexInCurrentBuffer < this.currentBufferLength) {
@@ -456,7 +456,7 @@ else if (n < 0) {
456456
}
457457
int len = (int) n;
458458
if (this.currentBuffer == null) {
459-
// this stream doesn't have any data in it
459+
// This stream doesn't have any data in it...
460460
return 0;
461461
}
462462
else {
@@ -506,7 +506,7 @@ public void updateMessageDigest(MessageDigest messageDigest) {
506506
*/
507507
public void updateMessageDigest(MessageDigest messageDigest, int len) {
508508
if (this.currentBuffer == null) {
509-
// this stream doesn't have any data in it
509+
// This stream doesn't have any data in it...
510510
return;
511511
}
512512
else if (len == 0) {

0 commit comments

Comments
 (0)