Ensure channel is set before returning from bind().

This commit is contained in:
Steven Smith 2015-08-21 20:08:13 -07:00
parent ce140f43d6
commit 9c1ac6aa9b

View file

@ -87,7 +87,18 @@ public class TcpConnectionListener implements ConnectionListener {
server.addSession(session);
}
}).group(this.group).localAddress(this.host, this.port).bind().addListener(new ChannelFutureListener() {
}).group(this.group).localAddress(this.host, this.port).bind();
if(wait) {
try {
future.sync();
} catch(InterruptedException e) {
}
channel = future.channel();
callback.run();
} else {
future.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture channelFuture) throws Exception {
if(channelFuture.isSuccess()) {
@ -99,12 +110,6 @@ public class TcpConnectionListener implements ConnectionListener {
}
}
});
if(wait) {
try {
future.sync();
} catch(InterruptedException e) {
}
}
}