ChannelFutureListener.operationComplete of SslHandler.handshake() Not Being Called on Android

陌路散爱 提交于 2019-12-04 18:24:19

netty might not handle the state of ChannelFuture returned to my application which calls SslHandler.handshake() correctly. I added hsFuture.setSuccess() to SslHandler.handshake() and my operationComplete gets called.

public ChannelFuture handshake() {
        ...
        if (exception == null) { // Began handshake successfully.
            try {
                final ChannelFuture hsFuture = handshakeFuture;
                wrapNonAppData(ctx, channel).addListener(new ChannelFutureListener() {
                    public void operationComplete(ChannelFuture future) throws Exception {
                        if (!future.isSuccess()) {
                            Throwable cause = future.getCause();
                            hsFuture.setFailure(cause);

                            fireExceptionCaught(ctx, cause);
                            if (closeOnSSLException) {
                                Channels.close(ctx, future(channel));
                            }
                        } else {
                            hsFuture.setSuccess();
                        }
                    }
                });
            } catch (SSLException e) {
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!