Ensure we only try to wrap if handler was not removed yet. (#11455)

Motivation:
7c57c4be17 did add a way to async sign keys but did not guard against the handler been removed before try to wrap in cause of an error which could lead to a harmless NPE.

Modifications:

Add check

Result:

No more harmless NPE
This commit is contained in:
Norman Maurer 2021-07-06 15:01:49 +02:00 committed by GitHub
parent 266c987339
commit ac91eaaae8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1258,9 +1258,12 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
ctx.fireUserEventTriggered(new SslHandshakeCompletionEvent(cause));
}
// We need to flush one time as there may be an alert that we should send to the remote peer because
// of the SSLException reported here.
wrapAndFlush(ctx);
// Let's check if the handler was removed in the meantime and so pendingUnencryptedWrites is null.
if (pendingUnencryptedWrites != null) {
// We need to flush one time as there may be an alert that we should send to the remote peer because
// of the SSLException reported here.
wrapAndFlush(ctx);
}
} catch (SSLException ex) {
logger.debug("SSLException during trying to call SSLEngine.wrap(...)" +
" because of an previous SSLException, ignoring...", ex);