Skip to content

Commit 0c733e1

Browse files
jiafu1115normanmaurer
authored andcommitted
[netty#2363] Correctly null out SelectionKey[] when selectAgain
Motivation: The prefix fix of netty#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
1 parent 1bee71f commit 0c733e1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

transport/src/main/java/io/netty/channel/nio/NioEventLoop.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,11 @@ private void processSelectedKeysOptimized(SelectionKey[] selectedKeys) {
475475
// null out entries in the array to allow to have it GC'ed once the Channel close
476476
// See https://github.com/netty/netty/issues/2363
477477
for (;;) {
478+
i++;
478479
if (selectedKeys[i] == null) {
479480
break;
480481
}
481482
selectedKeys[i] = null;
482-
i++;
483483
}
484484

485485
selectAgain();

0 commit comments

Comments
 (0)