From 4c06294c883e78581a686f3aafd287aa912ce9ae Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Thu, 20 Aug 2015 16:59:59 -0700 Subject: [PATCH] Ensure connection process has fully completed before ending wait loop. --- .../java/org/spacehq/packetlib/tcp/TcpClientSession.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/spacehq/packetlib/tcp/TcpClientSession.java b/src/main/java/org/spacehq/packetlib/tcp/TcpClientSession.java index 3971d8e4..b31088c5 100644 --- a/src/main/java/org/spacehq/packetlib/tcp/TcpClientSession.java +++ b/src/main/java/org/spacehq/packetlib/tcp/TcpClientSession.java @@ -96,15 +96,17 @@ public class TcpClientSession extends TcpSession { future.addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) throws Exception { - complete.set(true); if(!future.isSuccess() && future.cause() != null) { exceptionCaught(null, future.cause()); } } - }); - } catch(Throwable t) { + }).await(); + complete.set(true); + } catch(Throwable t) { exceptionCaught(null, t); + + complete.set(true); } } }).start();