@Override
    public void transferBufferOwnership(Object oldOwner, Object newOwner, Buffer buffer) {
        checkState(buffer.isBuffer(), "Only buffer supports transfer ownership.");
        decNumRequestedBuffer(oldOwner);
        incNumRequestedBuffer(newOwner);
        buffer.setRecycler(memorySegment -> recycleBuffer(newOwner, memorySegment));
    }
@Test
    void testTransferBufferOwnership() throws IOException {
        TieredStorageMemoryManagerImpl memoryManager =
                createStorageMemoryManager(
                        1, Collections.singletonList(new TieredStorageMemorySpec(this, 0)));
        BufferBuilder bufferBuilder = memoryManager.requestBufferBlocking(this);
        assertThat(memoryManager.numOwnerRequestedBuffer(this)).isEqualTo(1);

        BufferConsumer bufferConsumer = bufferBuilder.createBufferConsumerFromBeginning();
        Buffer buffer = bufferConsumer.build();
        bufferBuilder.close();
        bufferConsumer.close();
        Object newOwner = new Object();
        memoryManager.transferBufferOwnership(this, newOwner, buffer);
        assertThat(memoryManager.numOwnerRequestedBuffer(this)).isEqualTo(0);
        assertThat(memoryManager.numOwnerRequestedBuffer(newOwner)).isEqualTo(1);
        buffer.recycleBuffer();
        assertThat(memoryManager.numOwnerRequestedBuffer(newOwner)).isEqualTo(0);
    }