@Override public SSLEngineResult wrap(ByteBuffer[] appData,int offset,int length,ByteBuffer netData) throws SSLException {
  EngineArgs ea=new EngineArgs(appData,offset,length,netData);
  if (netData.remaining() < EngineOutputRecord.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;
  }
 finally {
    ea.resetLim();
  }
}

@ Override public SSLEngineResult wrap ( ByteBuffer [ ] appData , int offset , int length , ByteBuffer netData ) throws SSLException { EngineArgs ea = new EngineArgs ( appData , offset , length , netData ) ; if ( netData . remaining ( ) < EngineOutputRecord . 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 ; } finally { ea . resetLim ( ) ; } }
wraps a buffer . does a variety of checks before grabbing the wraplock , which blocks multiple wraps from occurring .
