Changed branching logic for LZFCompressor to return null only on error, and avoid checking in most circumstances

This commit is contained in:
Charles Allen 2014-11-25 12:53:11 -08:00
parent 9f945c2216
commit 6943db5251
1 changed files with 5 additions and 4 deletions

View File

@ -211,15 +211,16 @@ public class CompressedObjectStrategy<T extends Buffer> implements ObjectStrateg
@Override @Override
public byte[] compress(byte[] bytes) public byte[] compress(byte[] bytes)
{ {
LZFChunk chunk = null;
try (final ResourceHolder<ChunkEncoder> encoder = CompressedPools.getChunkEncoder()) { try (final ResourceHolder<ChunkEncoder> encoder = CompressedPools.getChunkEncoder()) {
chunk = encoder.get().encodeChunk(bytes, 0, bytes.length); final LZFChunk chunk = encoder.get().encodeChunk(bytes, 0, bytes.length);
return chunk.getData();
} }
catch (IOException e) { catch (IOException e) {
log.error(e, "IOException thrown while closing ChunkEncoder."); log.error(e, "IOException thrown while closing ChunkEncoder.");
} }
// IOException should be on ResourceHolder.close(), not encodeChunk, so this *should* never be null // IOException should be on ResourceHolder.close(), not encodeChunk, so this *should* never happen
return null == chunk ? null : chunk.getData(); return null;
} }
} }