From 0c733e14256715e64003a47aa75083c47c781208 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 ad64cd5f3a..c1bcf3a068 100644 --- a/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java +++ b/transport/src/main/java/io/netty/channel/nio/NioEventLoop.java @@ -475,11 +475,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();