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:
parent
1e810d370f
commit
36d06d016d
|
@ -368,7 +368,8 @@ public class GZIPContentDecoderTest
|
||||||
@ValueSource(longs = {INT_MAX, INT_MAX + 1, UINT_MAX, UINT_MAX + 1})
|
@ValueSource(longs = {INT_MAX, INT_MAX + 1, UINT_MAX, UINT_MAX + 1})
|
||||||
public void testLargeGzipStream(long origSize) throws IOException
|
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
|
// Create a buffer to use over and over again to produce the uncompressed input
|
||||||
byte[] cbuf = "0123456789ABCDEFGHIJKLMOPQRSTUVWXYZ".getBytes(StandardCharsets.UTF_8);
|
byte[] cbuf = "0123456789ABCDEFGHIJKLMOPQRSTUVWXYZ".getBytes(StandardCharsets.UTF_8);
|
||||||
|
@ -380,9 +381,7 @@ public class GZIPContentDecoderTest
|
||||||
off += len;
|
off += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
GZIPContentDecoder decoder = new GZIPContentDecoder(BUFSIZE);
|
GZIPDecoderOutputStream out = new GZIPDecoderOutputStream(new GZIPContentDecoder(BUFSIZE));
|
||||||
|
|
||||||
GZIPDecoderOutputStream out = new GZIPDecoderOutputStream(decoder);
|
|
||||||
GZIPOutputStream outputStream = new GZIPOutputStream(out, BUFSIZE);
|
GZIPOutputStream outputStream = new GZIPOutputStream(out, BUFSIZE);
|
||||||
|
|
||||||
for (long bytesLeft = origSize; bytesLeft > 0; )
|
for (long bytesLeft = origSize; bytesLeft > 0; )
|
||||||
|
@ -432,7 +431,7 @@ public class GZIPContentDecoderTest
|
||||||
@Override
|
@Override
|
||||||
public void write(int b) throws IOException
|
public void write(int b) throws IOException
|
||||||
{
|
{
|
||||||
write(new byte[]{(byte)(b & 0xFF)}, 0, 1);
|
write(new byte[]{(byte)b}, 0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue