Skip to content

Commit 9c4e3df

Browse files
committed
Increase StreamUtils.BUFFER_SIZE to 8192
This aligns the buffer size used in StreamUtils with the buffer sizes used throughout the JDK (see InputStream, BufferedInputStream, Files).
1 parent 40f9fe0 commit 9c4e3df

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
/**
3434
* Simple utility methods for dealing with streams. The copy methods of this class are
3535
* similar to those defined in {@link FileCopyUtils} except that all affected streams are
36-
* left open when done. All copy methods use a block size of 4096 bytes.
36+
* left open when done. All copy methods use a block size of 8192 bytes.
3737
*
3838
* <p>Mainly for use within the framework, but also useful for application code.
3939
*
@@ -48,7 +48,7 @@ public abstract class StreamUtils {
4848
/**
4949
* The default buffer size used when copying bytes.
5050
*/
51-
public static final int BUFFER_SIZE = 4096;
51+
public static final int BUFFER_SIZE = 8192;
5252

5353
private static final byte[] EMPTY_CONTENT = new byte[0];
5454

@@ -83,7 +83,7 @@ public static String copyToString(@Nullable InputStream in, Charset charset) thr
8383
return "";
8484
}
8585

86-
StringBuilder out = new StringBuilder(BUFFER_SIZE);
86+
StringBuilder out = new StringBuilder();
8787
InputStreamReader reader = new InputStreamReader(in, charset);
8888
char[] buffer = new char[BUFFER_SIZE];
8989
int charsRead;

0 commit comments

Comments
 (0)