From a3b46ec9d75f6e7552db51e9f8ac5ac1b493bf1e Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 8 Feb 2013 11:31:48 +0100 Subject: [PATCH] Fix a bug where a closed channel was tried to register with the eventloop --- .../src/main/java/io/netty/channel/AbstractChannel.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/transport/src/main/java/io/netty/channel/AbstractChannel.java b/transport/src/main/java/io/netty/channel/AbstractChannel.java index a8335f5cb7..3c96289e58 100644 --- a/transport/src/main/java/io/netty/channel/AbstractChannel.java +++ b/transport/src/main/java/io/netty/channel/AbstractChannel.java @@ -575,10 +575,6 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha assert eventLoop().inEventLoop(); - if (!ensureOpen(promise)) { - return; - } - // check if the eventLoop which was given is currently in the eventloop. // if that is the case we are safe to call register, if not we need to // schedule the execution as otherwise we may say some race-conditions. @@ -598,6 +594,11 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha private void register0(ChannelPromise promise) { try { + // check if the channel is still open as it could be closed in the mean time when the register + // call was outside of the eventLoop + if (!ensureOpen(promise)) { + return; + } Runnable postRegisterTask = doRegister(); registered = true; promise.setSuccess();