private void expandDecryptedNetBuffer() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "expandDecryptedNetBuffer");
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "callerRequiredAlloc=" + callerRequiredAllocation
                         + ", decNetReleaseReq=" + decryptedNetBufferReleaseRequired);
        }

        boolean expand = false;
        if (!getJITAllocateAction()) {
            // Caller provided original buffers.
            if (decryptedNetBufferReleaseRequired) {
                // Formerly they were found to be inadequate so we created new temp buffers.
                // The new temp buffers were sized based on the JSSE API.
                expand = true;
            } else {
                // Caller provided original buffers. However, they are not big
                // enough to contain the JSSE output. Allocate a new buffer with
                // default size from ssl engine. Its contents will be copied to
                // the caller's supplied buffer after the ssl engine runs.
                // Note, we have the responsibility of releasing this temporary buffer.
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                    Tr.event(tc, "Allocating substitute decNetworkBuffer");
                }
                decryptedNetBuffers = new WsByteBuffer[1];
                decryptedNetBuffers[0] = SSLUtils.allocateByteBuffer(getConnLink().getAppBufferSize(),
                                                                     getConfig().getDecryptBuffersDirect());
                decryptedNetBufferReleaseRequired = true;
            }
        } else {
            // Current buffers were allocated by us, but were still too small.
            expand = true;
        }

        if (expand) {
            // Expand the current set of buffers.
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Expanding set of buffers by one.");
            }
            WsByteBuffer tempBuffers[] = decryptedNetBuffers;
            decryptedNetBuffers = new WsByteBuffer[tempBuffers.length + 1];
            for (int i = 0; i < tempBuffers.length; i++) {
                decryptedNetBuffers[i] = tempBuffers[i];
            }
            // Allocate a new buffer and append it to the end of the existing array.
            // 316607 since this is not the first buffer, use the max size so we won't potentially
            // loop through creating many new buffers based on the current jit size, presuming
            // the same size will be used for future reads. Worst case is that we'll have
            // to copy the buffers for a future read with a small jit size.
            decryptedNetBuffers[tempBuffers.length] = SSLUtils.allocateByteBuffer(
                                                                                  getConnLink().getAppBufferSize(), getConfig().getDecryptBuffersDirect());
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(tc, "decryptedNetBuffers changed to ..."
                         + SSLUtils.getBufferTraceInfo(decryptedNetBuffers));
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "expandDecryptedNetBuffer");
        }
    }
private void expandDecryptedNetBuffer ( ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . entry ( tc , "expandDecryptedNetBuffer" ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "callerRequiredAlloc=" + callerRequiredAllocation + ", decNetReleaseReq=" + decryptedNetBufferReleaseRequired ) ; } boolean expand = false ; if ( ! getJITAllocateAction ( ) ) { if ( decryptedNetBufferReleaseRequired ) { expand = true ; } else { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEventEnabled ( ) ) { Tr . event ( tc , "Allocating substitute decNetworkBuffer" ) ; } decryptedNetBuffers = new WsByteBuffer [ 1 ] ; decryptedNetBuffers [ 0 ] = SSLUtils . allocateByteBuffer ( getConnLink ( ) . getAppBufferSize ( ) , getConfig ( ) . getDecryptBuffersDirect ( ) ) ; decryptedNetBufferReleaseRequired = true ; } } else { expand = true ; } if ( expand ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Expanding set of buffers by one." ) ; } WsByteBuffer tempBuffers [ ] = decryptedNetBuffers ; decryptedNetBuffers = new WsByteBuffer [ tempBuffers . length + 1 ] ; for ( int i = 0 ; i < tempBuffers . length ; i ++ ) { decryptedNetBuffers [ i ] = tempBuffers [ i ] ; } decryptedNetBuffers [ tempBuffers . length ] = SSLUtils . allocateByteBuffer ( getConnLink ( ) . getAppBufferSize ( ) , getConfig ( ) . getDecryptBuffersDirect ( ) ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEventEnabled ( ) ) { Tr . event ( tc , "decryptedNetBuffers changed to ..." + SSLUtils . getBufferTraceInfo ( decryptedNetBuffers ) ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . exit ( tc , "expandDecryptedNetBuffer" ) ; } }
This method is called when the SSL engine returns from unwrap indicating
that the output buffer was too small. If a buffer was provided by the
calling app channel to read into, it may have been too small. Note, we're
only able to use the first buffer in the provided array because of the limitations
of the unwrap method. If the buffer provided by the caller is too small,
one is allocated and sized according to the defaults in the SSL engine.
If the "too small" result came after using a buffer that
was allocated by us, we can't do anything but throw an Exception.
<p>
Note, if the calling channel provided buffers and we can't use them, we
will have to copy our results into the caller's buffers, save any data
that can't fit, and ultimately have the responsibility to free
the allocated buffer.
<p>