From fa806e58feee9ab66edf3c4f91c526c21fc9c520 Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Fri, 21 Aug 2015 21:14:17 -0700 Subject: [PATCH] Sync future instead of using listener. --- .../org/spacehq/packetlib/tcp/TcpClientSession.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/main/java/org/spacehq/packetlib/tcp/TcpClientSession.java b/src/main/java/org/spacehq/packetlib/tcp/TcpClientSession.java index c525b741..e11ddfc7 100644 --- a/src/main/java/org/spacehq/packetlib/tcp/TcpClientSession.java +++ b/src/main/java/org/spacehq/packetlib/tcp/TcpClientSession.java @@ -3,7 +3,6 @@ package org.spacehq.packetlib.tcp; import io.netty.bootstrap.Bootstrap; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelInitializer; import io.netty.channel.ChannelOption; import io.netty.channel.ChannelPipeline; @@ -89,16 +88,7 @@ public class TcpClientSession extends TcpSession { bootstrap.remoteAddress(host, port); - ChannelFuture future = bootstrap.connect(); - future.addListener(new ChannelFutureListener() { - @Override - public void operationComplete(ChannelFuture future) throws Exception { - if(!future.isSuccess()) { - exceptionCaught(null, future.cause()); - } - } - }).await(); - + ChannelFuture future = bootstrap.connect().sync(); if(future.isSuccess()) { while(!isConnected()) { try {