@Override protected void registerTask(AbstractNioChannel channel, ChannelFuture future) { final SocketAddress localAddress = channel.getLocalAddress(); if (localAddress == null) { if (future != null) { future.setFailure(new ClosedChannelException()); } close(channel, succeededFuture(channel)); return; } try { synchronized (channel.interestOpsLock) { channel.getJdkChannel().register(selector, channel.getRawInterestOps(), channel); } if (future != null) { future.setSuccess(); } } catch (final ClosedChannelException e) { if (future != null) { future.setFailure(e); } close(channel, succeededFuture(channel)); throw new ChannelException("Failed to register a socket to the selector.", e); } }