From f5ab1789488a26267ceaf4a3941a4df49b9db48c Mon Sep 17 00:00:00 2001 From: Robinson Date: Thu, 29 Apr 2021 09:59:42 +0200 Subject: [PATCH] Suppressed errors when starting/stopping an endpoint VERY quickly (as usually done in unit tests). These warnings, while noramlly VERY important, can be safely ignored. --- src/dorkbox/network/rmi/ResponseManager.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/dorkbox/network/rmi/ResponseManager.kt b/src/dorkbox/network/rmi/ResponseManager.kt index 8437eb50..d6b9ce06 100644 --- a/src/dorkbox/network/rmi/ResponseManager.kt +++ b/src/dorkbox/network/rmi/ResponseManager.kt @@ -20,6 +20,7 @@ import kotlinx.atomicfu.atomic import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.channels.ClosedSendChannelException import kotlinx.coroutines.delay import kotlinx.coroutines.launch import mu.KLogger @@ -71,8 +72,12 @@ internal class ResponseManager(private val logger: KLogger, private val actionDi // populate the array of randomly assigned ID's + waiters. This can happen in a new thread actionDispatch.launch { - for (it in ids) { - waiterCache.offer(ResponseWaiter(it)) + try { + for (it in ids) { + waiterCache.offer(ResponseWaiter(it)) + } + } catch (e: ClosedSendChannelException) { + // this can happen if we are starting/stopping an endpoint (and thus a response-manager) VERY quickly, and can be ignored } } }