@Override
            protected int netReadBufferSize() {
                ByteBuffer netReadBuffer = netReadBuffer();
                // netReadBufferSize() is invoked in SSLTransportLayer.read() prior to the read
                // operation. To avoid the read buffer being expanded too early, increase buffer size
                // only when read buffer is full. This ensures that BUFFER_UNDERFLOW is always
                // triggered in testNetReadBufferResize().
                boolean updateBufSize = netReadBuffer != null && !netReadBuffer().hasRemaining();
                return netReadBufSize.updateAndGet(super.netReadBufferSize(), updateBufSize);
            }
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