@Override
    public void close() {
        // Acquire the lock so that drain is guaranteed to complete the current batch
        appendLock.lock();
        List<CompletedBatch<T>> unwritten;
        try {
            unwritten = drain(Long.MAX_VALUE);
        } finally {
            appendLock.unlock();
        }
        unwritten.forEach(CompletedBatch::release);
    }
@Test
    public void testCloseWhenEmpty() {
        int leaderEpoch = 17;
        long baseOffset = 157;
        int lingerMs = 50;
        int maxBatchSize = 256;

        BatchAccumulator<String> acc = buildAccumulator(
            leaderEpoch,
            baseOffset,
            lingerMs,
            maxBatchSize
        );

        acc.close();
        Mockito.verifyNoInteractions(memoryPool);
    }