Index: java/org/apache/tomcat/util/buf/ByteChunk.java =================================================================== --- java/org/apache/tomcat/util/buf/ByteChunk.java (revision 1820969) +++ java/org/apache/tomcat/util/buf/ByteChunk.java (working copy) @@ -517,8 +517,13 @@ if( desiredSize <= buff.length ) { return; } + //If we are over 1Gb then doubling the buffer would overflow int + //so instead then set to the max value + if(this.buff.length >= 1 * 1024 * 1024 * 1024){ + tmp = new byte[Integer.MAX_VALUE - 1]; + } // grow in larger chunks - if( desiredSize < 2 * buff.length ) { + else if( desiredSize < 2 * buff.length ) { newSize= buff.length * 2; if( limit >0 && newSize > limit ) {