Avoid potential NPE for early close
@@ -387,11 +387,15 @@ protected void beginHandshake()
protected void cleanupHandshake()
{
- SecurityParameters securityParameters = getContext().getSecurityParameters();
+ TlsContext context = getContext();
+ if (null != context)
+ {
+ SecurityParameters securityParameters = context.getSecurityParameters();
if (null != securityParameters)
{
securityParameters.clear();
}
+ }
this.tlsSession = null;
this.sessionParameters = null;
@@ -1664,7 +1668,14 @@ public boolean isClosed()
public boolean isHandshaking()
{
- return !isClosed() && null != getContext().getSecurityParametersHandshake();
+ if (closed)
+ {
+ return false;
+ }
+
+ TlsContext context = getContext();
+
+ return null != context && null != context.getSecurityParametersHandshake();
}
protected short processMaxFragmentLengthExtension(Hashtable clientExtensions, Hashtable serverExtensions,
