code: public SSLEngineResult wrap(ByteBuffer [] appData,
              int offset, int length, ByteBuffer netData) throws SSLException {
  
          EngineArgs ea = new EngineArgs(appData, offset, length, netData);
  
          /*
           * We can be smarter about using smaller buffer sizes later.
           * For now, force it to be large enough to handle any
           * valid SSL/TLS record.
           */
          if (netData.remaining() < outputRecord.maxRecordSize) {
              return new SSLEngineResult(
                  Status.BUFFER_OVERFLOW, getHSStatus(null), 0, 0);
          }
  
          try {
              synchronized (wrapLock) {
                  return writeAppRecord(ea);
              }
          } catch (Exception e) {
              ea.resetPos();
  
              fatal(Alerts.alert_internal_error,
                  "problem wrapping app data", e);
              return null;  // make compiler happy
          } finally {
              /*
               * Just in case something didn't reset limits properly.
               */
              ea.resetLim();
          }
      }
docs: Wraps a buffer.  Does a variety of checks before grabbing
  the wrapLock, which blocks multiple wraps from occuring.