Don't automatically create the ByteArrayOutputStream with the full threshold - we probably won't need it in most cases.
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@708361
13f79535-47bb-0310-9956-
ffa450edef68
super(threshold);
this.outputFile = outputFile;
- memoryOutputStream = new ByteArrayOutputStream(threshold);
+ if (threshold < DefaultFileItemFactory.DEFAULT_SIZE_THRESHOLD) {
+ // Small threshold, use it
+ memoryOutputStream = new ByteArrayOutputStream(threshold);
+ } else {
+ // Large threshold. Use default and array will expand if required
+ memoryOutputStream = new ByteArrayOutputStream(
+ DefaultFileItemFactory.DEFAULT_SIZE_THRESHOLD);
+ }
currentOutputStream = memoryOutputStream;
}