Source:
private boolean connectOrContinueConnecting() throws InterruptedException { if (this.connectFuture == null) { log.debug(String.format("%s beginning connection process.", this.getName())); this.connectFuture = this.bootstrap.connect( this.pushManager.getEnvironment().getApnsGatewayHost(), this.pushManager.getEnvironment().getApnsGatewayPort()); } this.connectFuture.await(); if (this.connectFuture.isSuccess()) { log.debug(String.format("%s connected.", this.getName())); this.channel = this.connectFuture.channel(); this.channel.config().setAutoClose(false); if (this.handshakeFuture == null) { log.debug(String.format("%s waiting for TLS handshake.", this.getName())); final SslHandler sslHandler = this.channel.pipeline().get(SslHandler.class); if (sslHandler != null) { this.handshakeFuture = sslHandler.handshakeFuture(); } else { log.error(String.format("%s failed to get SSL handler and could not wait for a TLS handshake.", this.getName())); this.closeChannelAndLogOutcome(this.channel); this.connectFuture = null; this.handshakeFuture = null; return false; } } this.handshakeFuture.await(); if (this.handshakeFuture.isSuccess()) { log.debug(String.format("%s successfully completed TLS handshake.", this.getName())); this.connectFuture = null; this.handshakeFuture = null; return true; } else { log.error(String.format("%s failed to complete TLS handshake with APNs gateway.", this.getName()), this.handshakeFuture.cause()); this.closeChannelAndLogOutcome(this.channel); this.connectFuture = null; this.handshakeFuture = null; return false; } } else { log.error(String.format("%s failed to connect to APNs gateway.", this.getName()), connectFuture.cause()); Thread.sleep(CONNECT_EXCEPTION_WAIT); this.connectFuture = null; return false; } }

Target:
private boolean connectOrContinueConnecting() throws InterruptedException { if (this.connectFuture == null) { log.debug(String.format("%s beginning connection process.", this.getName())); this.connectFuture = this.bootstrap.connect( this.pushManager.getEnvironment().getApnsGatewayHost(), this.pushManager.getEnvironment().getApnsGatewayPort()); } this.connectFuture.await(); if (this.connectFuture.isSuccess()) { log.debug(String.format("%s connected.", this.getName())); this.channel = this.connectFuture.channel(); this.channel.config().setAutoClose(false); if (this.handshakeFuture == null) { log.debug(String.format("%s waiting for TLS handshake.", this.getName())); final SslHandler sslHandler = this.channel.pipeline().get(SslHandler.class); if (sslHandler != null) { this.handshakeFuture = sslHandler.handshakeFuture(); } else { log.error(String.format("%s failed to get SSL handler and could not wait for a TLS handshake.", this.getName())); this.closeChannelAndLogOutcome(this.channel); this.connectFuture = null; this.handshakeFuture = null; return false; } } this.handshakeFuture.await(); final boolean finished; if (this.handshakeFuture.isSuccess()) { log.debug(String.format("%s successfully completed TLS handshake.", this.getName())); finished = true; } else { log.error(String.format("%s failed to complete TLS handshake with APNs gateway.", this.getName()), this.handshakeFuture.cause()); this.closeChannelAndLogOutcome(this.channel); finished = false; } this.connectFuture = null; this.handshakeFuture = null; return finished; } else { log.error(String.format("%s failed to connect to APNs gateway.", this.getName()), connectFuture.cause()); Thread.sleep(CONNECT_EXCEPTION_WAIT); this.connectFuture = null; return false; } }