[#1523] Fix bug which lead to have SelectedKeys handled two times and so caused a NPE on heavy load

This commit is contained in:
Norman Maurer 2013-07-04 16:15:33 +02:00
parent cad7c1f1b0
commit 2bda1b530a

View File

@ -52,6 +52,7 @@ public final class NioEventLoop extends SingleThreadEventLoop {
private static final InternalLogger logger = InternalLoggerFactory.getInstance(NioEventLoop.class);
private static final int CLEANUP_INTERVAL = 256; // XXX Hard-coded value, but won't need customization.
private static final boolean DISABLE_KEYSET_OPTIMIZATION =
SystemPropertyUtil.getBoolean("io.netty.noKeySetOptimization", false);
@ -470,6 +471,13 @@ public final class NioEventLoop extends SingleThreadEventLoop {
if (needsToSelectAgain) {
selectAgain();
// Need to flip the optimized selectedKeys to get the right reference to the array
// and reset the index to -1 which will then set to 0 on the for loop
// to start over again.
//
// See https://github.com/netty/netty/issues/1523
selectedKeys = this.selectedKeys.flip();
i = -1;
}
}
}