diff --git a/transport-sctp/src/main/java/io/netty/channel/sctp/SctpWorker.java b/transport-sctp/src/main/java/io/netty/channel/sctp/SctpWorker.java index 10f597fcad..2c11779ead 100644 --- a/transport-sctp/src/main/java/io/netty/channel/sctp/SctpWorker.java +++ b/transport-sctp/src/main/java/io/netty/channel/sctp/SctpWorker.java @@ -215,7 +215,6 @@ public class SctpWorker extends NioWorker { protected void connect(SelectionKey k) { final SctpClientChannel ch = (SctpClientChannel) k.attachment(); try { - // TODO: Remove cast if (ch.getJdkChannel().finishConnect()) { registerTask(ch, ch.connectFuture); } @@ -358,7 +357,13 @@ public class SctpWorker extends NioWorker { ((SctpChannelImpl) channel).setConnected(); future.setSuccess(); } - + + if (!server) { + if (!((SctpClientChannel) channel).boundManually) { + fireChannelBound(channel, localAddress); + } + fireChannelConnected(channel, remoteAddress); + } } catch (IOException e) { if (future != null) { future.setFailure(e); @@ -369,13 +374,6 @@ public class SctpWorker extends NioWorker { "Failed to register a socket to the selector.", e); } } - - if (!server) { - if (!((SctpClientChannel) channel).boundManually) { - fireChannelBound(channel, localAddress); - } - fireChannelConnected(channel, remoteAddress); - } } @Override diff --git a/transport/src/main/java/io/netty/channel/socket/nio/NioWorker.java b/transport/src/main/java/io/netty/channel/socket/nio/NioWorker.java index 5da091776a..0f3ace41de 100644 --- a/transport/src/main/java/io/netty/channel/socket/nio/NioWorker.java +++ b/transport/src/main/java/io/netty/channel/socket/nio/NioWorker.java @@ -140,6 +140,10 @@ public class NioWorker extends SelectorEventLoop { } future.setSuccess(); } + if (server || !((NioClientSocketChannel) channel).boundManually) { + fireChannelBound(channel, localAddress); + } + fireChannelConnected(channel, remoteAddress); } catch (IOException e) { if (future != null) { @@ -151,11 +155,6 @@ public class NioWorker extends SelectorEventLoop { "Failed to register a socket to the selector.", e); } } - - if (server || !((NioClientSocketChannel) channel).boundManually) { - fireChannelBound(channel, localAddress); - } - fireChannelConnected(channel, remoteAddress); } }