Author: britter Date: Sun May 22 14:31:38 2016 New Revision: 1745058 URL: http://svn.apache.org/viewvc?rev=1745058&view=rev Log: Adopt changes made in r1743480 by jochen:
Attempt to fix a possible performance issue with large boundaries. Preliminary, may be rolled back shortly. Modified: commons/proper/fileupload/branches/b1_3/src/main/java/org/apache/commons/fileupload/MultipartStream.java Modified: commons/proper/fileupload/branches/b1_3/src/main/java/org/apache/commons/fileupload/MultipartStream.java URL: http://svn.apache.org/viewvc/commons/proper/fileupload/branches/b1_3/src/main/java/org/apache/commons/fileupload/MultipartStream.java?rev=1745058&r1=1745057&r2=1745058&view=diff ============================================================================== --- commons/proper/fileupload/branches/b1_3/src/main/java/org/apache/commons/fileupload/MultipartStream.java (original) +++ commons/proper/fileupload/branches/b1_3/src/main/java/org/apache/commons/fileupload/MultipartStream.java Sun May 22 14:31:38 2016 @@ -325,12 +325,6 @@ public class MultipartStream { if (boundary == null) { throw new IllegalArgumentException("boundary may not be null"); } - - this.input = input; - this.bufSize = bufSize; - this.buffer = new byte[bufSize]; - this.notifier = pNotifier; - // We prepend CR/LF to the boundary to chop trailing CR/LF from // body-data tokens. this.boundaryLength = boundary.length + BOUNDARY_PREFIX.length; @@ -338,6 +332,12 @@ public class MultipartStream { throw new IllegalArgumentException( "The buffer size specified for the MultipartStream is too small"); } + + this.input = input; + this.bufSize = Math.max(bufSize, boundaryLength*2); + this.buffer = new byte[this.bufSize]; + this.notifier = pNotifier; + this.boundary = new byte[this.boundaryLength]; this.keepRegion = this.boundary.length;