Browse Source

FastByteArrayInputStream consistently returns -1 when no data available

Issue: SPR-13858
pull/947/merge
Juergen Hoeller 9 years ago
parent
commit
5d4547d343
  1. 12
      spring-core/src/main/java/org/springframework/util/FastByteArrayOutputStream.java

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -361,7 +361,7 @@ public class FastByteArrayOutputStream extends OutputStream { @@ -361,7 +361,7 @@ public class FastByteArrayOutputStream extends OutputStream {
@Override
public int read() {
if (this.currentBuffer == null) {
// this stream doesn't have any data in it
// This stream doesn't have any data in it...
return -1;
}
else {
@ -412,8 +412,8 @@ public class FastByteArrayOutputStream extends OutputStream { @@ -412,8 +412,8 @@ public class FastByteArrayOutputStream extends OutputStream {
}
else {
if (this.currentBuffer == null) {
// this stream doesn't have any data in it
return 0;
// This stream doesn't have any data in it...
return -1;
}
else {
if (this.nextIndexInCurrentBuffer < this.currentBufferLength) {
@ -456,7 +456,7 @@ public class FastByteArrayOutputStream extends OutputStream { @@ -456,7 +456,7 @@ public class FastByteArrayOutputStream extends OutputStream {
}
int len = (int) n;
if (this.currentBuffer == null) {
// this stream doesn't have any data in it
// This stream doesn't have any data in it...
return 0;
}
else {
@ -506,7 +506,7 @@ public class FastByteArrayOutputStream extends OutputStream { @@ -506,7 +506,7 @@ public class FastByteArrayOutputStream extends OutputStream {
*/
public void updateMessageDigest(MessageDigest messageDigest, int len) {
if (this.currentBuffer == null) {
// this stream doesn't have any data in it
// This stream doesn't have any data in it...
return;
}
else if (len == 0) {

Loading…
Cancel
Save