WriteFuture writeFuture = null;
try {
IoBuffer writeBuffer = fetchOutNetBuffer();
writeFuture = new DefaultWriteFuture(session);
parent.filterWrite(nextFilter, session, new DefaultWriteRequest(
writeBuffer, writeFuture));
// loop while more writes required to complete handshake
while (needToCompleteHandshake()) {
try {
handshake(nextFilter);
} catch (SSLException ssle) {
SSLException newSsle = new SSLHandshakeException(
"SSL handshake failed.");
newSsle.initCause(ssle);
throw newSsle;
}
IoBuffer outNetBuffer = fetchOutNetBuffer();
if (outNetBuffer != null && outNetBuffer.hasRemaining()) {
writeFuture = new DefaultWriteFuture(session);
parent.filterWrite(nextFilter, session,
new DefaultWriteRequest(outNetBuffer, writeFuture));
}
}
} finally {
writingEncryptedData = false;
}