@Test
    public void testCleanupMemoryAvailabilityWaiterOnBlockTimeout() throws Exception {
        BufferPool pool = new BufferPool(2, 1, metrics, time, metricGroup);
        pool.allocate(1, maxBlockTimeMs);
        try {
            pool.allocate(2, maxBlockTimeMs);
            fail("The buffer allocated more memory than its maximum value 2");
        } catch (BufferExhaustedException e) {
            // this is good
        }
        assertEquals(0, pool.queued());
        assertEquals(1, pool.availableMemory());
    }
Test if the  waiter that is waiting on availability of more memory is cleaned up when a timeout occurs
clients/src/test/java/org/apache/kafka/clients/producer/internals/BufferPoolTest.java