public static void resetBuffersAfterJSSE ( WsByteBuffer [ ] buffers , int [ ] limitInfo ) { // Handle case where not changes were made in recent call to adjustBuffersForJSSE if ( limitInfo == null ) { return ; } int bufferIndex = limitInfo [ 0 ] ; int bufferLimit = limitInfo [ 1 ] ; // Ensure buffer index is within array bounds. if ( buffers . length > bufferIndex ) { WsByteBuffer buffer = buffers [ bufferIndex ] ; // Ensure the buffer is not null and the limit won't be set beyond the capacity if ( ( buffer != null ) && ( buffer . capacity ( ) >= bufferLimit ) ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "resetBuffersAfterJSSE: buffer [" + bufferIndex + "] from " + buffer . limit ( ) + " to " + bufferLimit ) ; } // Make the adjustment. buffer . limit ( bufferLimit ) ; } } }
This method is called after a call is made to adjustBuffersForJSSE followed by a call to wrap or unwrap in the JSSE . It restores the saved limit in the buffer that was modified . A few extra checks are done here to prevent any problems during odd code paths in the future .