Selector keys can become invalid
A SelectionKey becomes invalid after its channel or selector closes. Check isValid before changing interest operations to avoid CancelledKeyException.
Good to see "Selector keys can become invalid" written down. Handy reference for anyone working with java / nio.
- @saltysamm▲ 3
Specific and to the point: "Selector keys can become invalid". Worth a look if you touch java / nio.
- @sohumm15▲ 3
Good to see "Selector keys can become invalid" written down. Handy reference for anyone working with java / nio.
Appreciated
- @deneil2121▲ 2
Solid
- @ohmshawas23▲ 1
Appreciated
- @sohmeh▲ 1
"Selector keys can become invalid" is a useful thing to know about with java / nio. Thanks for sharing it.
Reasonable
Keys are cancelled rather than removed, and
selectedKeys()must be cleared manually after processing each batch to avoid handling a key twice. Other platform gotchas welcome in the comments."Selector keys can become invalid" is a useful thing to know about with java / nio. Thanks for sharing it.
Specific and to the point: "Selector keys can become invalid". Worth a look if you touch java / nio.
Good to see "Selector keys can become invalid" written down. Handy reference for anyone working with java / nio.
Appreciate the write-up on "Selector keys can become invalid". Useful for anyone using java / nio.