[#1624] Fix resource leak when writing to a closed / not-open channel

This commit is contained in:
Norman Maurer 2013-07-22 10:59:06 +02:00
parent 0f6cc0cc7b
commit 81612f8e9b

View File

@ -19,6 +19,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ByteBufHolder; import io.netty.buffer.ByteBufHolder;
import io.netty.util.DefaultAttributeMap; import io.netty.util.DefaultAttributeMap;
import io.netty.util.ReferenceCountUtil;
import io.netty.util.internal.EmptyArrays; import io.netty.util.internal.EmptyArrays;
import io.netty.util.internal.PlatformDependent; import io.netty.util.internal.PlatformDependent;
import io.netty.util.internal.ThreadLocalRandom; import io.netty.util.internal.ThreadLocalRandom;
@ -620,6 +621,8 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
} else { } else {
promise.tryFailure(CLOSED_CHANNEL_EXCEPTION); promise.tryFailure(CLOSED_CHANNEL_EXCEPTION);
} }
// release message now to prevent resource-leak
ReferenceCountUtil.release(msg);
} else { } else {
outboundBuffer.addMessage(msg, promise); outboundBuffer.addMessage(msg, promise);
} }