code: public static int adjustBufferForJSSE(WsByteBuffer buffer, int maxBufferSize) {
          int limit = -1;
          if (null != buffer) {
              int size = buffer.remaining();
              if (maxBufferSize < size) {
                  limit = buffer.limit();
                  // Adjust the limit to the max allowed.
                  int overFlow = size - maxBufferSize;
                  buffer.limit(limit - overFlow);
                  if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                      Tr.debug(tc, "adjustBufferForJSSE: from " + limit + " to " + buffer.limit());
                  }
              }
          }
          return limit;
      }
docs: The purpose of this method is to prepare the input buffer to be sent
  into a call to wrap or unwrap in the JSSE considering the limitations
  about how much data can be present in each buffer. This amount is determined
  by the amount of data between position and limit.
  
  @param buffer being examined which will be sent into the JSSE
  @param maxBufferSize maximum size allowed
  @return int - limit to restore later, -1 if no changes required