From c4a49110efe47c7f5554dc52b829b4ae53884f95 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 19 Feb 2015 14:30:39 +1100 Subject: [PATCH] 460210 - ExecutionStragegy producer for SelectManager calls onOpen from produce method fixed NPE on connection destroy for stopped selector --- .../java/org/eclipse/jetty/io/ManagedSelector.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java index 0af27cb1c9c..3e727e9b653 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java @@ -120,7 +120,8 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump _actions.offer(change); if (_selecting) { - _selector.wakeup(); + if (_selector!=null) + _selector.wakeup(); // To avoid the extra select wakeup. _selecting=false; } @@ -708,8 +709,12 @@ public class ManagedSelector extends AbstractLifeCycle implements Runnable, Dump @Override public void run() { - Selector selector=_selector; - _selector=null; + Selector selector; + try(SpinLock.Lock lock = _lock.lock()) + { + selector=_selector; + _selector=null; + } closeNoExceptions(selector); _latch.countDown(); }