Fix ZStd decompressions streams being to long
This commit is contained in:
+2
-1
@@ -61,7 +61,8 @@ public class DhDataInputStream extends DataInputStream
|
||||
ByteArrayInputStream byteArrayInputStream;
|
||||
if (compressionMode == EDhApiDataCompressionMode.Z_STD_BLOCK)
|
||||
{
|
||||
byteArrayInputStream = new ByteArrayInputStream(PooledZstdDecompressor.decompressFrame(byteArray, checkout));
|
||||
ByteArrayList pooledByteArrayList = PooledZstdDecompressor.decompressFrame(byteArray, checkout);
|
||||
byteArrayInputStream = new ByteArrayInputStream(pooledByteArrayList.elements(), 0, pooledByteArrayList.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+3
-3
@@ -12,7 +12,7 @@ public class PooledZstdDecompressor
|
||||
* Replaces {@link Zstd#decompress} so we can use a pooled byte array
|
||||
* which significantly reduces GC pressure.
|
||||
*/
|
||||
public static byte[] decompressFrame(byte[] src, PhantomArrayListCheckout checkout) throws ZstdException
|
||||
public static ByteArrayList decompressFrame(byte[] src, PhantomArrayListCheckout checkout) throws ZstdException
|
||||
{
|
||||
int compressedSize = (int) Zstd.findFrameCompressedSize(src, 0);
|
||||
int contentSize = (int) Zstd.getFrameContentSize(src, 0, compressedSize);
|
||||
@@ -30,7 +30,7 @@ public class PooledZstdDecompressor
|
||||
ByteArrayList destination = checkout.getByteArray(0, contentSize);
|
||||
return decompress(src, compressedSize, contentSize, destination);
|
||||
}
|
||||
private static byte[] decompress(byte[] src, int srcSize, int originalSize, ByteArrayList destination) throws ZstdException
|
||||
private static ByteArrayList decompress(byte[] src, int srcSize, int originalSize, ByteArrayList destination) throws ZstdException
|
||||
{
|
||||
if (originalSize < 0)
|
||||
{
|
||||
@@ -49,7 +49,7 @@ public class PooledZstdDecompressor
|
||||
destination.size(size); // this assumes the size will only be smaller than the expected
|
||||
}
|
||||
|
||||
return destination.elements();
|
||||
return destination;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user