From 9acf12fa4b149ecfc32c5b9b5fe8485f11d7dd30 Mon Sep 17 00:00:00 2001 From: markt Date: Mon, 27 Oct 2008 22:40:48 +0000 Subject: [PATCH] Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=46075 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 --- .../tomcat/util/http/fileupload/DeferredFileOutputStream.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/java/org/apache/tomcat/util/http/fileupload/DeferredFileOutputStream.java b/java/org/apache/tomcat/util/http/fileupload/DeferredFileOutputStream.java index 5ba416565..569eb6210 100644 --- a/java/org/apache/tomcat/util/http/fileupload/DeferredFileOutputStream.java +++ b/java/org/apache/tomcat/util/http/fileupload/DeferredFileOutputStream.java @@ -84,7 +84,14 @@ public class DeferredFileOutputStream 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; } -- 2.11.0