Fixed an issue: NETTY-15 (NullPointerException in SslHandler if handshake() method is not called explicitly.)
* Modified SslHandler.setHandshakeSuccess/Failure(..) to create a new handshakeFuture if not created yet.
This commit is contained in:
parent
2d6cfe9af6
commit
49bac1aa73
@ -328,7 +328,7 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
|
|||||||
runDelegatedTasks();
|
runDelegatedTasks();
|
||||||
break;
|
break;
|
||||||
case FINISHED:
|
case FINISHED:
|
||||||
setHandshakeSuccess();
|
setHandshakeSuccess(channel);
|
||||||
default:
|
default:
|
||||||
if (result.getStatus() == Status.CLOSED) {
|
if (result.getStatus() == Status.CLOSED) {
|
||||||
success = false;
|
success = false;
|
||||||
@ -341,7 +341,7 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
|
|||||||
} catch (SSLException e) {
|
} catch (SSLException e) {
|
||||||
success = false;
|
success = false;
|
||||||
if (handshaking) {
|
if (handshaking) {
|
||||||
setHandshakeFailure(e);
|
setHandshakeFailure(channel, e);
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
@ -413,7 +413,7 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
|
|||||||
|
|
||||||
switch (result.getHandshakeStatus()) {
|
switch (result.getHandshakeStatus()) {
|
||||||
case FINISHED:
|
case FINISHED:
|
||||||
setHandshakeSuccess();
|
setHandshakeSuccess(channel);
|
||||||
break;
|
break;
|
||||||
case NEED_TASK:
|
case NEED_TASK:
|
||||||
runDelegatedTasks();
|
runDelegatedTasks();
|
||||||
@ -426,7 +426,7 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
|
|||||||
}
|
}
|
||||||
} catch (SSLException e) {
|
} catch (SSLException e) {
|
||||||
if (handshaking) {
|
if (handshaking) {
|
||||||
setHandshakeFailure(e);
|
setHandshakeFailure(channel, e);
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
@ -463,7 +463,7 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
|
|||||||
runDelegatedTasks();
|
runDelegatedTasks();
|
||||||
break;
|
break;
|
||||||
case FINISHED:
|
case FINISHED:
|
||||||
setHandshakeSuccess();
|
setHandshakeSuccess(channel);
|
||||||
case NOT_HANDSHAKING:
|
case NOT_HANDSHAKING:
|
||||||
wrap(ctx, channel);
|
wrap(ctx, channel);
|
||||||
break loop;
|
break loop;
|
||||||
@ -483,7 +483,7 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
|
|||||||
}
|
}
|
||||||
} catch (SSLException e) {
|
} catch (SSLException e) {
|
||||||
if (handshaking) {
|
if (handshaking) {
|
||||||
setHandshakeFailure(e);
|
setHandshakeFailure(channel, e);
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
@ -498,18 +498,26 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHandshakeSuccess() {
|
private void setHandshakeSuccess(Channel channel) {
|
||||||
synchronized (handshakeLock) {
|
synchronized (handshakeLock) {
|
||||||
handshaking = false;
|
handshaking = false;
|
||||||
handshaken = true;
|
handshaken = true;
|
||||||
|
|
||||||
|
if (handshakeFuture != null) {
|
||||||
|
handshakeFuture = future(channel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
handshakeFuture.setSuccess();
|
handshakeFuture.setSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHandshakeFailure(SSLException cause) {
|
private void setHandshakeFailure(Channel channel, SSLException cause) {
|
||||||
synchronized (handshakeLock) {
|
synchronized (handshakeLock) {
|
||||||
handshaking = false;
|
handshaking = false;
|
||||||
handshaken = false;
|
handshaken = false;
|
||||||
|
|
||||||
|
if (handshakeFuture != null) {
|
||||||
|
handshakeFuture = future(channel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
handshakeFuture.setFailure(cause);
|
handshakeFuture.setFailure(cause);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user