Search code examples
javanetwork-programmingnettynio

Is this ChannelFuture listener registration robust?


Below is some code snippet from the book < Netty in Action >. enter image description here

I am wondering if the connect action finished after 1 and before 2, will the ChannelFutureListener ever get a chance to be notified?


Solution

  • Check the Netty javadoc, specifically for addListener. It states that the listener will be notified immediately if the operation is already complete.

    So the answer is yes, it's robust.