If a Selector is closed at around the same thing that another thread attempts to set the interest set of a SelectionKey representing a registration of a channel with that selector then it's possible for interestOps(int) to throw ClosedSelectorException.
interestOps(int), interestOpsAnd(int) and interestOpsOr(int) should not throw ClosedSelectorException, they throw CancelledKeyException when the key is cancelled (closing a selector will cancelled the keys).
This is small regression that crept in when the Selector implementations were re-implemented in JDK 11. More specifically, each of the Selector implementations defines a setEventOps method that queues the key for the registration. The setEventOps should not call ensureOpen (the ensureOpen can be removed in most cases).
interestOps(int), interestOpsAnd(int) and interestOpsOr(int) should not throw ClosedSelectorException, they throw CancelledKeyException when the key is cancelled (closing a selector will cancelled the keys).
This is small regression that crept in when the Selector implementations were re-implemented in JDK 11. More specifically, each of the Selector implementations defines a setEventOps method that queues the key for the registration. The setEventOps should not call ensureOpen (the ensureOpen can be removed in most cases).
- links to
-
Commit(master) openjdk/jdk/9f03f687
-
Review(master) openjdk/jdk/20269