@Test
  public void testCheckRefCountOnlyWithRecycler() {
    TrackingSingleByteBuff singleBuff = new TrackingSingleByteBuff(ByteBuffer.allocate(1));
    singleBuff.get();
    assertEquals(1, singleBuff.getCheckRefCountCalls());
    assertEquals(0, singleBuff.getRefCntCalls());
    singleBuff = new TrackingSingleByteBuff(() -> {
      // do nothing, just so we dont use NONE recycler
    }, ByteBuffer.allocate(1));
    singleBuff.get();
    assertEquals(1, singleBuff.getCheckRefCountCalls());
    assertEquals(1, singleBuff.getRefCntCalls());

    TrackingMultiByteBuff multiBuff = new TrackingMultiByteBuff(ByteBuffer.allocate(1));

    multiBuff.get();
    assertEquals(1, multiBuff.getCheckRefCountCalls());
    assertEquals(0, multiBuff.getRefCntCalls());
    multiBuff = new TrackingMultiByteBuff(() -> {
      // do nothing, just so we dont use NONE recycler
    }, ByteBuffer.allocate(1));
    multiBuff.get();
    assertEquals(1, multiBuff.getCheckRefCountCalls());
    assertEquals(1, multiBuff.getRefCntCalls());
  }
Tests that we only call the logic in checkRefCount for ByteBuff's that have a non-NONE
recycler.
hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestByteBuffAllocator.java