kevins-29 commented on code in PR #4585:
URL: https://github.com/apache/hadoop/pull/4585#discussion_r925006154
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodecPool.java:
##########
@@ -189,4 +198,54 @@ public void testDecompressorNotReturnSameInstance() {
CodecPool.returnDecompressor(decompressor);
}
}
+
+ @Test(timeout = 10000)
+ public void testDoNotPoolCompressorNotUseableAfterReturn() throws
IOException {
+
+ final GzipCodec gzipCodec = new GzipCodec();
+ gzipCodec.setConf(new Configuration());
+
+ // BuiltInGzipCompressor is an explicit example of a Compressor with the
@DoNotPool annotation
+ final Compressor compressor = new BuiltInGzipCompressor(new
Configuration());
+ CodecPool.returnCompressor(compressor);
+
+ try (CompressionOutputStream outputStream =
+ gzipCodec.createOutputStream(new ByteArrayOutputStream(),
compressor)) {
+ outputStream.write(1);
+ fail("Compressor from Codec with @DoNotPool should not be useable after
returning to CodecPool");
+ } catch (NullPointerException exception) {
Review Comment:
Unfortunately I couldn't find another way to test that the underlying
Compressor/Decompress has been closed. There is `finished` but that is set by
`reset()` and has different semantics.
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/compress/TestCodecPool.java:
##########
@@ -189,4 +198,54 @@ public void testDecompressorNotReturnSameInstance() {
CodecPool.returnDecompressor(decompressor);
}
}
+
+ @Test(timeout = 10000)
+ public void testDoNotPoolCompressorNotUseableAfterReturn() throws
IOException {
+
+ final GzipCodec gzipCodec = new GzipCodec();
+ gzipCodec.setConf(new Configuration());
+
+ // BuiltInGzipCompressor is an explicit example of a Compressor with the
@DoNotPool annotation
+ final Compressor compressor = new BuiltInGzipCompressor(new
Configuration());
+ CodecPool.returnCompressor(compressor);
+
+ try (CompressionOutputStream outputStream =
+ gzipCodec.createOutputStream(new ByteArrayOutputStream(),
compressor)) {
+ outputStream.write(1);
Review Comment:
Thank you.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]