Fix NPE which can accour when the Selector is closed but there are still timeout tasks to handle on client mode. The NPE does not have any bad side-effects, but its still ugly. See #685
This commit is contained in:
parent
8c2a1d1a64
commit
b1cfaad9bf
@ -187,6 +187,12 @@ class NioClientSocketPipelineSink extends AbstractNioChannelSink {
|
||||
private final int subId;
|
||||
private final TimerTask wakeupTask = new TimerTask() {
|
||||
public void run(Timeout timeout) throws Exception {
|
||||
// This is needed to prevent a possible race that can lead to a NPE
|
||||
// when the selector is closed before this is run
|
||||
//
|
||||
// See https://github.com/netty/netty/issues/685
|
||||
Selector selector = NioClientSocketPipelineSink.Boss.this.selector;
|
||||
|
||||
if (selector != null) {
|
||||
if (wakenUp.compareAndSet(false, true)) {
|
||||
selector.wakeup();
|
||||
|
Loading…
x
Reference in New Issue
Block a user