mirror of https://github.com/apache/druid.git
Fix CompressedObjectStrategy LZFCompressor to ignore error on close of ResourceHolder
This commit is contained in:
parent
f8ce68565b
commit
fc9a54ea48
|
@ -46,8 +46,7 @@ public class CompressedObjectStrategy<T extends Buffer> implements ObjectStrateg
|
|||
|
||||
public static enum CompressionStrategy
|
||||
{
|
||||
LZF((byte) 0x0)
|
||||
{
|
||||
LZF((byte) 0x0) {
|
||||
@Override
|
||||
public Decompressor getDecompressor()
|
||||
{
|
||||
|
@ -61,8 +60,7 @@ public class CompressedObjectStrategy<T extends Buffer> implements ObjectStrateg
|
|||
}
|
||||
},
|
||||
|
||||
LZ4((byte) 0x1)
|
||||
{
|
||||
LZ4((byte) 0x1) {
|
||||
@Override
|
||||
public Decompressor getDecompressor()
|
||||
{
|
||||
|
@ -75,8 +73,7 @@ public class CompressedObjectStrategy<T extends Buffer> implements ObjectStrateg
|
|||
return LZ4Compressor.defaultCompressor;
|
||||
}
|
||||
},
|
||||
UNCOMPRESSED((byte) 0xFF)
|
||||
{
|
||||
UNCOMPRESSED((byte) 0xFF) {
|
||||
@Override
|
||||
public Decompressor getDecompressor()
|
||||
{
|
||||
|
@ -212,13 +209,15 @@ public class CompressedObjectStrategy<T extends Buffer> implements ObjectStrateg
|
|||
@Override
|
||||
public byte[] compress(byte[] bytes)
|
||||
{
|
||||
LZFChunk chunk = null;
|
||||
try (final ResourceHolder<ChunkEncoder> encoder = CompressedPools.getChunkEncoder()) {
|
||||
LZFChunk chunk = encoder.get().encodeChunk(bytes, 0, bytes.length);
|
||||
return chunk.getData();
|
||||
chunk = encoder.get().encodeChunk(bytes, 0, bytes.length);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw Throwables.propagate(e);
|
||||
// Silently Ignore if error on close
|
||||
}
|
||||
// IOException should be on ResourceHolder.close(), not encodeChunk, so this *should* never be null
|
||||
return null == chunk ? null : chunk.getData();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue