Ensure connect promise is notifed before fireChannelActive() is called. Related to [#4927]

Motivation:

We should always first notify the promise before trigger an event through the pipeline to be consistent.

Modifications:

Ensure we notify the promise before fire event.

Result:

Consistent behavior
This commit is contained in:
Norman Maurer 2016-03-10 14:58:46 +01:00
parent 4fb585965c
commit e3bf679998

View File

@ -500,6 +500,9 @@ public final class EpollDatagramChannel extends AbstractEpollChannel implements
EpollDatagramChannel.this.local = fd().localAddress();
success = true;
// First notify the promise before notifying the handler.
channelPromise.trySuccess();
// Regardless if the connection attempt was cancelled, channelActive() event should be triggered,
// because what happened is what happened.
if (!wasActive && isActive()) {
@ -509,12 +512,11 @@ public final class EpollDatagramChannel extends AbstractEpollChannel implements
if (!success) {
doClose();
} else {
channelPromise.setSuccess();
connected = true;
}
}
} catch (Throwable cause) {
channelPromise.setFailure(cause);
channelPromise.tryFailure(cause);
}
}