Issue #4415 - Addressing Gzip Decoding of large files

+ Addressing PR review

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
This commit is contained in:
Joakim Erdfelt 2019-12-12 13:23:44 -06:00
parent 1e810d370f
commit 36d06d016d
No known key found for this signature in database
GPG Key ID: 2D0E1FB8FE4B68B4
1 changed files with 4 additions and 5 deletions

View File

@ -368,7 +368,8 @@ public class GZIPContentDecoderTest
@ValueSource(longs = {INT_MAX, INT_MAX + 1, UINT_MAX, UINT_MAX + 1})
public void testLargeGzipStream(long origSize) throws IOException
{
final int BUFSIZE = (1 * 1024 * 1024); // 1MB
// Size chosen for trade off between speed of I/O vs speed of Gzip
final int BUFSIZE = 1024 * 1024;
// Create a buffer to use over and over again to produce the uncompressed input
byte[] cbuf = "0123456789ABCDEFGHIJKLMOPQRSTUVWXYZ".getBytes(StandardCharsets.UTF_8);
@ -380,9 +381,7 @@ public class GZIPContentDecoderTest
off += len;
}
GZIPContentDecoder decoder = new GZIPContentDecoder(BUFSIZE);
GZIPDecoderOutputStream out = new GZIPDecoderOutputStream(decoder);
GZIPDecoderOutputStream out = new GZIPDecoderOutputStream(new GZIPContentDecoder(BUFSIZE));
GZIPOutputStream outputStream = new GZIPOutputStream(out, BUFSIZE);
for (long bytesLeft = origSize; bytesLeft > 0; )
@ -432,7 +431,7 @@ public class GZIPContentDecoderTest
@Override
public void write(int b) throws IOException
{
write(new byte[]{(byte)(b & 0xFF)}, 0, 1);
write(new byte[]{(byte)b}, 0, 1);
}
}
}