Fixed occasional on the selector - it shouldn't crash the application

This commit is contained in:
Christian Basler 2017-07-22 08:01:59 +02:00
parent 6c04aa683e
commit d9e52c85c3

View File

@ -203,6 +203,7 @@ class NioNetworkHandler : NetworkHandler, InternalContext.ContextHolder {
serverChannel.register(selector, OP_ACCEPT, null) serverChannel.register(selector, OP_ACCEPT, null)
while (selector.isOpen) { while (selector.isOpen) {
try {
selector.select(1000) selector.select(1000)
val keyIterator = selector.selectedKeys().iterator() val keyIterator = selector.selectedKeys().iterator()
while (keyIterator.hasNext()) { while (keyIterator.hasNext()) {
@ -271,6 +272,9 @@ class NioNetworkHandler : NetworkHandler, InternalContext.ContextHolder {
} }
} }
} }
} catch (e: CancelledKeyException) {
LOG.debug(e.message, e)
}
// set interest ops // set interest ops
for ((connection, selectionKey) in connections) { for ((connection, selectionKey) in connections) {
try { try {