90d89 < private final SSLBuffer outPlain; 167d165 < this.outPlain = bufferManagementStrategy.constructBuffer(appBuffersize); 242d239 < this.outPlain.release(); 298c295 < // Generate outgoing handshake data --- > // Generate outgoing handshake data 300,313c297,298 < // Acquire buffers < ByteBuffer outPlainBuf = this.outPlain.acquire(); < final ByteBuffer outEncryptedBuf = this.outEncrypted.acquire(); < < // Perform operations < outPlainBuf.flip(); < result = doWrap(outPlainBuf, outEncryptedBuf); < outPlainBuf.compact(); < < // Release outPlain if empty < if (outPlainBuf.position() == 0) { < this.outPlain.release(); < outPlainBuf = null; < } --- > // Acquire buffer > final ByteBuffer outEncryptedBuf = this.outEncrypted.acquire(); 314a300,301 > // Just wrap an empty buffer because there is no data to write. > result = doWrap(ByteBuffer.allocate(0), outEncryptedBuf); 316,319c303,306 < if (result.getStatus() != Status.OK) { < handshaking = false; < } < break; --- > if (result.getStatus() != Status.OK) { > handshaking = false; > } > break; 572,595c559,562 < if (this.outPlain.hasData()) { < // Acquire buffers < final ByteBuffer outPlainBuf = this.outPlain.acquire(); < final ByteBuffer outEncryptedBuf = this.outEncrypted.acquire(); < < // Perform operations < outPlainBuf.flip(); < doWrap(outPlainBuf, outEncryptedBuf); < outPlainBuf.compact(); < < // Release outPlain if empty < if (outPlainBuf.position() == 0) { < this.outPlain.release(); < } < } < if (!this.outPlain.hasData()) { < final ByteBuffer outEncryptedBuf = this.outEncrypted.acquire(); < final SSLEngineResult result = doWrap(src, outEncryptedBuf); < if (result.getStatus() == Status.CLOSED) { < this.status = CLOSED; < } < return result.bytesConsumed(); < } else { < return 0; --- > final ByteBuffer outEncryptedBuf = this.outEncrypted.acquire(); > final SSLEngineResult result = doWrap(src, outEncryptedBuf); > if (result.getStatus() == Status.CLOSED) { > this.status = CLOSED; 596a564 > return result.bytesConsumed(); 655d622 < this.outPlain.release(); 727,728c694 < || this.outEncrypted.hasData() < || this.outPlain.hasData(); --- > || this.outEncrypted.hasData(); 795,796d760 < buffer.append("]["); < buffer.append(!this.outPlain.hasData() ? 0 : outPlain.acquire().position());