Source:
<code>private HandshakeStatus unwrap( ByteBuffer buffer ) throws IOException { HandshakeStatus handshakeStatus; if ( channel.read( cipherIn ) < 0 ) { throw new ClientException( "Failed to establish SSL socket connection." ); } cipherIn.flip(); Status status = null; do { status = sslEngine.unwrap( cipherIn, plainIn ).getStatus(); if ( status == OK ) { plainIn.flip(); bufferCopy( plainIn, buffer ); plainIn.compact(); } else if ( status == BUFFER_OVERFLOW || (status == BUFFER_UNDERFLOW && cipherIn.limit() == cipherIn.capacity()) ) { int oldSize = plainIn.capacity(); if ( oldSize >= bufferMax ) { throw new ClientException( "Failed to enlarge a buffer: plainIn.size = " + oldSize + ", cipherIn.size = " + cipherIn.capacity() + ". The maximum size for a buffer is " + bufferMax ); } int newSize = Math.min( oldSize * 2, bufferMax ); ByteBuffer newPlainIn = ByteBuffer.allocateDirect( newSize ); bufferCopy( plainIn, newPlainIn ); plainIn = newPlainIn; <START> logger.debug( "Enlarged application input buffer from " + oldSize + " to " + newSize + <END> ". This operation should be a rare operation." ); if ( newSize > cipherIn.capacity() ) { oldSize = cipherIn.capacity(); ByteBuffer newCipherIn = ByteBuffer.allocateDirect( newSize ); bufferCopy( cipherIn, newCipherIn ); cipherIn = newCipherIn; logger.debug( "Enlarged network input buffer from " + oldSize + " to " + newSize + ". This operation should be a rare operation." ); } return sslEngine.getHandshakeStatus(); } handshakeStatus = runDelegatedTasks(); } while ( cipherIn.hasRemaining() && handshakeStatus == NEED_UNWRAP && status != BUFFER_UNDERFLOW ); cipherIn.compact(); return handshakeStatus; }</code><technical_language>this is in a super low-level loop of driver, do explicit check for isDebugEnabled construct string? create a stringBuilder, chararray a string object time a network packet is pulled in</technical_language>

Target:
private HandshakeStatus unwrap( ByteBuffer buffer ) throws IOException { HandshakeStatus handshakeStatus = sslEngine.getHandshakeStatus(); if ( channel.read( cipherIn ) < 0 ) { throw new ClientException( "Failed to establish SSL socket connection." ); } cipherIn.flip(); Status status = null; do { status = sslEngine.unwrap( cipherIn, plainIn ).getStatus(); switch ( status ) { case OK: plainIn.flip(); bufferCopy( plainIn, buffer ); plainIn.compact(); handshakeStatus = runDelegatedTasks(); break; case BUFFER_OVERFLOW: int curAppSize = plainIn.capacity(); int appSize = sslEngine.getSession().getApplicationBufferSize(); int newAppSize = appSize + plainIn.remaining(); if ( newAppSize > appSize * 2 ) { throw new ClientException( String.format( "Failed ro enlarge application buffer from %s to %s, as the maximum " + "buffer size allowed is %s. The content in the buffer is: %s\n", curAppSize, newAppSize, appSize * 2, BytePrinter.hex( plainIn ) ) ); } ByteBuffer newPlainIn = ByteBuffer.allocateDirect( newAppSize ); newPlainIn.put( plainIn ); plainIn = newPlainIn; logger.debug( "Enlarged application input buffer from %s to %s. " + "This operation should be a rare operation.", curAppSize, newAppSize ); break; case BUFFER_UNDERFLOW: int curNetSize = cipherIn.capacity(); int netSize = sslEngine.getSession().getPacketBufferSize(); if ( netSize > curNetSize ) { ByteBuffer newCipherIn = ByteBuffer.allocateDirect( netSize ); newCipherIn.put( cipherIn ); cipherIn = newCipherIn; logger.debug( "Enlarged network input buffer from %s to %s. " + "This operation should be a rare operation.", curNetSize, netSize ); } return handshakeStatus; default: throw new ClientException( "Got unexpected status " + status ); } } while ( cipherIn.hasRemaining() ); cipherIn.compact(); return handshakeStatus; }