The asynchronous operations should not throw an exception directly
This commit is contained in:
parent
2fea789309
commit
2ac4719fae
@ -305,21 +305,28 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
|
|||||||
* @return a {@link ChannelFuture} which is notified when the handshake
|
* @return a {@link ChannelFuture} which is notified when the handshake
|
||||||
* succeeds or fails.
|
* succeeds or fails.
|
||||||
*/
|
*/
|
||||||
public ChannelFuture handshake(Channel channel) throws SSLException {
|
public ChannelFuture handshake(Channel channel) {
|
||||||
// FIXME do not throw SSLException - return a failed future.
|
|
||||||
ChannelFuture handshakeFuture;
|
ChannelFuture handshakeFuture;
|
||||||
synchronized (handshakeLock) {
|
synchronized (handshakeLock) {
|
||||||
if (handshaking) {
|
if (handshaking) {
|
||||||
return this.handshakeFuture;
|
return this.handshakeFuture;
|
||||||
} else {
|
} else {
|
||||||
|
try {
|
||||||
engine.beginHandshake();
|
engine.beginHandshake();
|
||||||
runDelegatedTasks();
|
runDelegatedTasks();
|
||||||
handshakeFuture = this.handshakeFuture = future(channel);
|
handshakeFuture = this.handshakeFuture = future(channel);
|
||||||
|
} catch (SSLException e) {
|
||||||
|
handshakeFuture = this.handshakeFuture = failedFuture(channel, e);
|
||||||
|
}
|
||||||
handshaking = true;
|
handshaking = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
wrapNonAppData(context(channel), channel);
|
wrapNonAppData(context(channel), channel);
|
||||||
|
} catch (SSLException e) {
|
||||||
|
handshakeFuture.setFailure(e);
|
||||||
|
}
|
||||||
return handshakeFuture;
|
return handshakeFuture;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,11 +334,14 @@ public class SslHandler extends FrameDecoder implements ChannelDownstreamHandler
|
|||||||
* Sends an SSL {@code close_notify} message to the specified channel and
|
* Sends an SSL {@code close_notify} message to the specified channel and
|
||||||
* destroys the underlying {@link SSLEngine}.
|
* destroys the underlying {@link SSLEngine}.
|
||||||
*/
|
*/
|
||||||
public ChannelFuture close(Channel channel) throws SSLException {
|
public ChannelFuture close(Channel channel) {
|
||||||
// FIXME do not throw SSLException - return a failed future.
|
try {
|
||||||
ChannelHandlerContext ctx = context(channel);
|
ChannelHandlerContext ctx = context(channel);
|
||||||
engine.closeOutbound();
|
engine.closeOutbound();
|
||||||
return wrapNonAppData(ctx, channel);
|
return wrapNonAppData(ctx, channel);
|
||||||
|
} catch (SSLException e) {
|
||||||
|
return failedFuture(channel, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChannelHandlerContext context(Channel channel) {
|
private ChannelHandlerContext context(Channel channel) {
|
||||||
|
Loading…
Reference in New Issue
Block a user