Source:
<code>public ChannelFuture connect(final Subscriber<? super ObservableConnection<I, O>> subscriber, RxClient.ServerInfo serverInfo, final ClientConnectionFactory<I, O, ? extends ObservableConnection<I, O>> connectionFactory) { final ChannelFuture connectFuture = clientBootstrap.connect(serverInfo.getHost(), serverInfo.getPort()); subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { if (!connectFuture.isDone()) { connectFuture.cancel(true); } } })); connectFuture.addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { subscriber.onError(future.cause()); } else { ChannelPipeline pipeline = future.channel().pipeline(); ChannelHandlerContext ctx = pipeline.lastContext(); final ObservableConnection<I, O> newConnection = connectionFactory.newConnection(ctx); ChannelHandler lifecycleHandler = pipeline.get(RxRequiredConfigurator.CONN_LIFECYCLE_HANDLER_NAME); if (null == lifecycleHandler) { onNewConnection(newConnection, subscriber); } else { @SuppressWarnings("unchecked") ConnectionLifecycleHandler<I, O> handler = (ConnectionLifecycleHandler<I, O>) lifecycleHandler; <START> ChannelHandler sslHandler = pipeline.get(SslHandler.class); <END> if (null == sslHandler) { handler.setConnection(newConnection); onNewConnection(newConnection, subscriber); } else { handler.setConnectionAction(new Action0() { @Override public void call() { onNewConnection(newConnection, subscriber); } }); } } } } }); return connectFuture; }</code><technical_language>I this code simplified SSLHandler.handshakeFuture() adding a listener it, instead of registering action ConnectionLifecycleHandler</technical_language>

Target:
public ChannelFuture connect(final Subscriber<? super ObservableConnection<I, O>> subscriber, RxClient.ServerInfo serverInfo, final ClientConnectionFactory<I, O, ? extends ObservableConnection<I, O>> connectionFactory) { final ChannelFuture connectFuture = clientBootstrap.connect(serverInfo.getHost(), serverInfo.getPort()); subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { if (!connectFuture.isDone()) { connectFuture.cancel(true); } } })); connectFuture.addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { subscriber.onError(future.cause()); } else { ChannelPipeline pipeline = future.channel().pipeline(); ChannelHandlerContext ctx = pipeline.lastContext(); final ObservableConnection<I, O> newConnection = connectionFactory.newConnection(ctx); ChannelHandler lifecycleHandler = pipeline.get(RxRequiredConfigurator.CONN_LIFECYCLE_HANDLER_NAME); if (null == lifecycleHandler) { onNewConnection(newConnection, subscriber); } else { @SuppressWarnings("unchecked") ConnectionLifecycleHandler<I, O> handler = (ConnectionLifecycleHandler<I, O>) lifecycleHandler; SslHandler sslHandler = pipeline.get(SslHandler.class); if (null == sslHandler) { handler.setConnection(newConnection); onNewConnection(newConnection, subscriber); } else { sslHandler.handshakeFuture().addListener(new GenericFutureListener<Future<? super Channel>>() { @Override public void operationComplete(Future<? super Channel> future) throws Exception { onNewConnection(newConnection, subscriber); } }); } } } } }); return connectFuture; }