use of com.github.luben.zstd.ZstdInputStream in project netty by netty.
the class ZstdEncoderTest method decompress.
@Override
protected ByteBuf decompress(ByteBuf compressed, int originalLength) throws Exception {
InputStream is = new ByteBufInputStream(compressed, true);
ZstdInputStream zstdIs = null;
byte[] decompressed = new byte[originalLength];
try {
zstdIs = new ZstdInputStream(is);
int remaining = originalLength;
while (remaining > 0) {
int read = zstdIs.read(decompressed, originalLength - remaining, remaining);
if (read > 0) {
remaining -= read;
} else {
break;
}
}
assertEquals(-1, zstdIs.read());
} finally {
if (zstdIs != null) {
zstdIs.close();
} else {
is.close();
}
}
return Unpooled.wrappedBuffer(decompressed);
}
Aggregations