Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package com.rabbitmq.stream.compression;

import com.github.luben.zstd.Zstd;
import com.github.luben.zstd.ZstdInputStream;
import com.github.luben.zstd.ZstdInputStreamNoFinalizer;
import com.github.luben.zstd.ZstdOutputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -101,7 +101,7 @@ public OutputStream compress(OutputStream outputStream) {
@Override
public InputStream decompress(InputStream inputStream) {
try {
return new ZstdInputStream(inputStream);
return new ZstdInputStreamNoFinalizer(inputStream);
} catch (IOException e) {
throw new CompressionException("Error while creating Zstd compression input stream", e);
}
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/com/rabbitmq/stream/impl/ServerFrameHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -562,16 +562,23 @@ static int handleDeliver(
if (comp.code() != Compression.NONE.code()) {
CompressionCodec compressionCodec = client.compressionCodecFactory.get(comp);
ByteBuf outBb = client.channel.alloc().heapBuffer(uncompressedDataSize);
ByteBuf slice = message.slice(message.readerIndex(), dataSize);
InputStream inputStream = compressionCodec.decompress(new ByteBufInputStream(slice));
byte[] inBuffer = new byte[Math.min(uncompressedDataSize, 1024)];
int n;
ByteBuf slice = message.slice(message.readerIndex(), dataSize);
InputStream inputStream = compressionCodec.decompress(new ByteBufInputStream(slice));
try {
while (-1 != (n = inputStream.read(inBuffer))) {
outBb.writeBytes(inBuffer, 0, n);
}
} catch (IOException e) {
throw new StreamException("Error while uncompressing sub-entry", e);
} finally {
try {
inputStream.close();
} catch (IOException e) {
throw new StreamException(
"Error while closing sub-entry compressed input stream", e);
}
}
message.readerIndex(message.readerIndex() + dataSize);
bbToReadFrom = outBb;
Expand Down
Loading