Created
January 30, 2019 15:56
-
-
Save enebo/fa4788666069865f061b4d52f9ca2453 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git show ce341a3 | |
commit ce341a313838db73c6dbc535db08419358645d0a | |
Author: Charles Oliver Nutter <headius@headius.com> | |
Date: Wed Dec 19 17:10:12 2018 -0600 | |
Ignore closed selectors when returning to pool. | |
It's unclear why the selector is closing but if it's closed it's | |
not usable anymore. We can ignore it and a new one will get | |
created for future use. | |
This relates to guard/rb-inotify#91. | |
diff --git a/core/src/main/java/org/jruby/util/io/SelectorPool.java b/core/src/main/java/org/jruby/util/io/SelectorPool.java | |
index 1ca0b811f9..090c91a4d7 100644 | |
--- a/core/src/main/java/org/jruby/util/io/SelectorPool.java | |
+++ b/core/src/main/java/org/jruby/util/io/SelectorPool.java | |
@@ -30,6 +30,7 @@ | |
package org.jruby.util.io; | |
import java.io.IOException; | |
+import java.nio.channels.ClosedSelectorException; | |
import java.nio.channels.SelectionKey; | |
import java.nio.channels.Selector; | |
import java.util.ArrayList; | |
@@ -85,19 +86,23 @@ public class SelectorPool { | |
* @param selector the selector to put back | |
*/ | |
public void put(Selector selector) { | |
- for (SelectionKey key : selector.keys()) { | |
- if (key != null) { | |
- key.cancel(); | |
+ try { | |
+ for (SelectionKey key : selector.keys()) { | |
+ if (key != null) { | |
+ key.cancel(); | |
+ } | |
} | |
- } | |
- try { | |
- selector.selectNow(); | |
- } catch (Exception e) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment