From c2c0d01ddb1c0e5301d58973ab3f2f3b3e805614 Mon Sep 17 00:00:00 2001 From: "fu.jian" Date: Fri, 8 Jan 2016 14:11:58 +0800 Subject: [PATCH] [#2363] Correctly null out SelectionKey[] when selectAgain Motivation: The prefix fix of #2363 did not correctly handle the case when selectAgain is true and so missed to null out entries. Modifications: Move the i++ from end of loop to beginning of loop Result: Entries in the array will be null out so allow to have these GC'ed once the Channel close --- transport/src/main/java/io/netty/channel/nio/NioEventLoop.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java b/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java index f231771b61..43973f7986 100644 --- a/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java +++ b/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java @@ -476,11 +476,11 @@ public final class NioEventLoop extends SingleThreadEventLoop { // null out entries in the array to allow to have it GC'ed once the Channel close // See https://github.com/netty/netty/issues/2363 for (;;) { + i++; if (selectedKeys[i] == null) { break; } selectedKeys[i] = null; - i++; } selectAgain();