private void getEncryptedAppBuffer ( int requested_size ) throws IOException { final int size = Math . max ( getConnLink ( ) . getPacketBufferSize ( ) , requested_size ) ; synchronized ( closeSync ) { if ( closeCalled ) { IOException up = new IOException ( "Operation failed due to connection close detected" ) ; throw up ; } if ( null != this . encryptedAppBuffer ) { if ( size <= this . encryptedAppBuffer . capacity ( ) ) { // current buffer exists and is big enough this . encryptedAppBuffer . clear ( ) ; return ; } // exists but is too small this . encryptedAppBuffer . release ( ) ; this . encryptedAppBuffer = null ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEventEnabled ( ) ) { Tr . event ( tc , "Allocating encryptedAppBuffer, size=" + size ) ; } // Allocate the encrypted data buffer this . encryptedAppBuffer = SSLUtils . allocateByteBuffer ( size , getConfig ( ) . getEncryptBuffersDirect ( ) ) ; } }
Make sure that an output buffer is ready for encryption use . This will always allocate a minimum of the current SSLSession packet size .