fix compression-strategy-test (#12575)

fixes an issue caused by a test modification in #12408 that was closing buffers allocated by the compression strategy instead of allowing the closer to do it
This commit is contained in:
Clint Wylie 2022-05-31 11:48:32 -07:00 committed by GitHub
parent 02ae3e74ff
commit 0640c9c9ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 15 deletions

View File

@ -126,21 +126,15 @@ public class CompressionStrategyTest
.allocateOutBuffer(originalData.length, closer);
ByteBuffer compressionIn = compressionStrategy.getCompressor()
.allocateInBuffer(originalData.length, closer);
try {
compressionIn.put(originalData);
compressionIn.position(0);
ByteBuffer compressed = compressionStrategy.getCompressor().compress(compressionIn, compressionOut);
ByteBuffer output = compressionStrategy.getCompressor().allocateOutBuffer(originalData.length, closer);
compressionStrategy.getDecompressor().decompress(compressed, compressed.remaining(), output);
byte[] checkArray = new byte[DATA_SIZER];
output.get(checkArray);
Assert.assertArrayEquals("Uncompressed data does not match", originalData, checkArray);
return true;
}
finally {
ByteBufferUtils.free(compressionIn);
ByteBufferUtils.free(compressionOut);
}
compressionIn.put(originalData);
compressionIn.position(0);
ByteBuffer compressed = compressionStrategy.getCompressor().compress(compressionIn, compressionOut);
ByteBuffer output = compressionStrategy.getCompressor().allocateOutBuffer(originalData.length, closer);
compressionStrategy.getDecompressor().decompress(compressed, compressed.remaining(), output);
byte[] checkArray = new byte[DATA_SIZER];
output.get(checkArray);
Assert.assertArrayEquals("Uncompressed data does not match", originalData, checkArray);
return true;
}
)
);