public long readUnconsumedDecData() {
        long totalBytesRead = 0L;

        // Determine if data is left over from a former read request.
        if (unconsumedDecData != null) {
            // Left over data exists. Is there enough to satisfy the request?
            if (getBuffer() == null) {
                // Caller needs us to allocate the buffer to return.
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Caller needs buffer, unconsumed data: "
                                 + SSLUtils.getBufferTraceInfo(unconsumedDecData));
                }
                // Note, data of unconsumedDecData buffer array should be starting
                // at position 0 in the first buffer.
                totalBytesRead = SSLUtils.lengthOf(unconsumedDecData, 0);
                // First release any existing buffers in decryptedNetBuffers array.
                cleanupDecBuffers();
                callerRequiredAllocation = true;
                // Note, it is the responsibility of the calling channel to release this buffer.
                decryptedNetBuffers = unconsumedDecData;
                // Set left over buffers to null to note that they are no longer in use.
                unconsumedDecData = null;
                if ((decryptedNetLimitInfo == null)
                    || (decryptedNetLimitInfo.length != decryptedNetBuffers.length)) {
                    decryptedNetLimitInfo = new int[decryptedNetBuffers.length];
                }
                SSLUtils.getBufferLimits(decryptedNetBuffers, decryptedNetLimitInfo);
            } else {
                // Caller provided buffers for read. We need to copy the left over
                // data to those buffers.
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Caller provided buffers, unconsumed data: "
                                 + SSLUtils.getBufferTraceInfo(unconsumedDecData));
                }
                // First release any existing buffers in decryptedNetBuffers array.
                cleanupDecBuffers();
                // The unconsumedDecData buffers have the data to copy to the user buffers.
                // The copyDataToCallerBuffers method copies from decryptedNetBuffers, so assign it.
                decryptedNetBuffers = unconsumedDecData;
                // Copy the outputbuffer to the buffers provided by the caller.
                totalBytesRead = copyDataToCallerBuffers();
                // Null out the reference to the overflow buffers.
                decryptedNetBuffers = null;
            }
        }
        return totalBytesRead;
    }
public long readUnconsumedDecData ( ) { long totalBytesRead = 0L ; if ( unconsumedDecData != null ) { if ( getBuffer ( ) == null ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Caller needs buffer, unconsumed data: " + SSLUtils . getBufferTraceInfo ( unconsumedDecData ) ) ; } totalBytesRead = SSLUtils . lengthOf ( unconsumedDecData , 0 ) ; cleanupDecBuffers ( ) ; callerRequiredAllocation = true ; decryptedNetBuffers = unconsumedDecData ; unconsumedDecData = null ; if ( ( decryptedNetLimitInfo == null ) || ( decryptedNetLimitInfo . length != decryptedNetBuffers . length ) ) { decryptedNetLimitInfo = new int [ decryptedNetBuffers . length ] ; } SSLUtils . getBufferLimits ( decryptedNetBuffers , decryptedNetLimitInfo ) ; } else { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Caller provided buffers, unconsumed data: " + SSLUtils . getBufferTraceInfo ( unconsumedDecData ) ) ; } cleanupDecBuffers ( ) ; decryptedNetBuffers = unconsumedDecData ; totalBytesRead = copyDataToCallerBuffers ( ) ; decryptedNetBuffers = null ; } } return totalBytesRead ; }
This method is called when a read is requested. It checks to see if any
data is left over from the previous read, but there wasn't space in the
buffers to store the result.

@return number of bytes copied from the left over buffer