[#1523] Fix bug which lead to have SelectedKeys handled two times and so caused a NPE on heavy load
This commit is contained in:
parent
cad7c1f1b0
commit
2bda1b530a
@ -52,6 +52,7 @@ public final class NioEventLoop extends SingleThreadEventLoop {
|
|||||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(NioEventLoop.class);
|
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 int CLEANUP_INTERVAL = 256; // XXX Hard-coded value, but won't need customization.
|
||||||
|
|
||||||
private static final boolean DISABLE_KEYSET_OPTIMIZATION =
|
private static final boolean DISABLE_KEYSET_OPTIMIZATION =
|
||||||
SystemPropertyUtil.getBoolean("io.netty.noKeySetOptimization", false);
|
SystemPropertyUtil.getBoolean("io.netty.noKeySetOptimization", false);
|
||||||
|
|
||||||
@ -470,6 +471,13 @@ public final class NioEventLoop extends SingleThreadEventLoop {
|
|||||||
|
|
||||||
if (needsToSelectAgain) {
|
if (needsToSelectAgain) {
|
||||||
selectAgain();
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user