@Override
            protected boolean flush(ByteBuffer buf) throws IOException {
                if (!buf.hasRemaining())
                    return super.flush(buf);
                if (numFlushesRemaining.decrementAndGet() == 0 && !ready())
                    flushFailureAction.run();
                else if (numDelayedFlushesRemaining.getAndDecrement() != 0)
                    return false;
                resetDelayedFlush();
                return super.flush(buf);
            }
SSLTransportLayer with overrides for testing including:
<ul>
<li>Overrides for packet and application buffer size to test buffer resize code path.
The overridden buffer size starts with a small value and increases in size when the buffer size
is retrieved to handle overflow/underflow, until the actual session buffer size is reached.</li>
<li>IOException injection for reads and writes for testing exception handling during handshakes.</li>
<li>Delayed writes to test handshake failure notifications to peer</li>
</ul>
clients/src/test/java/org/apache/kafka/common/network/SslTransportLayerTest.java