Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8336339

(se) SelectionKey.interestOps(int) should not throw ClosedSelectorException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • 11, 24
    • core-libs
    • None
    • b08

      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).

            alanb Alan Bateman
            alanb Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: