From 1b122190f11571c57ea6c5075158240b1c17e5b5 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 16 Apr 2023 10:20:44 +0100 Subject: [PATCH] [core] CoroutineOnDemandValueScope: ignore multiple `finishImpl` --- .../kotlin/network/auth/CoroutineOnDemandValueScope.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mirai-core/src/commonMain/kotlin/network/auth/CoroutineOnDemandValueScope.kt b/mirai-core/src/commonMain/kotlin/network/auth/CoroutineOnDemandValueScope.kt index 71ba2169e..0365060a7 100644 --- a/mirai-core/src/commonMain/kotlin/network/auth/CoroutineOnDemandValueScope.kt +++ b/mirai-core/src/commonMain/kotlin/network/auth/CoroutineOnDemandValueScope.kt @@ -99,7 +99,7 @@ internal class CoroutineOnDemandValueScope( private fun finishImpl(exception: Throwable?) { state.loop { state -> when (state) { - is ProducerState.Finished -> throw state.createAlreadyFinishedException(exception) + is ProducerState.Finished -> {} // ignore else -> { if (compareAndSetState(state, ProducerState.Finished(state, exception))) { val cancellationException = kotlinx.coroutines.CancellationException("Finished", exception) @@ -153,6 +153,7 @@ internal class CoroutineOnDemandValueScope( } return null } + else -> throw IllegalProducerStateException(state) } }