@Test(timeout = 10000)
  public void testDoNotPoolDecompressorNotUseableAfterReturn() throws Exception {

    final GzipCodec gzipCodec = new GzipCodec();
    gzipCodec.setConf(new Configuration());

    final Random random = new Random();
    final byte[] bytes = new byte[1024];
    random.nextBytes(bytes);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (OutputStream outputStream = gzipCodec.createOutputStream(baos)) {
      outputStream.write(bytes);
    }

    final byte[] gzipBytes = baos.toByteArray();
    final ByteArrayInputStream bais = new ByteArrayInputStream(gzipBytes);

    // BuiltInGzipDecompressor is an explicit example of a Decompressor
    // with the @DoNotPool annotation
    final Decompressor decompressor = new BuiltInGzipDecompressor();
    CodecPool.returnDecompressor(decompressor);

    final CompressionInputStream inputStream = gzipCodec.createInputStream(bais, decompressor);
    boolean passed = false;
    try {
      inputStream.read();
    } catch (AlreadyClosedException e) {
      if (e.getMessage().contains("decompress called on closed decompressor")) {
        passed = true;
      }
    }

    if (!passed) {
      fail("Decompressor from Codec with @DoNotPool should not be "
        + "useable after returning to CodecPool");
    }
  }
Along with CodecPool, this is copied from the class of the same name in hadoop-common. Modified
to accommodate changes to HBase's CodecPool.
hbase-common/src/test/java/org/apache/hadoop/hbase/io/compress/TestCodecPool.java