Преглед на файлове

[core] CoroutineOnDemandValueScope: ignore multiple `finishImpl`

Him188 преди 2 години
родител
ревизия
1b122190f1
променени са 1 файла, в които са добавени 2 реда и са изтрити 1 реда
  1. 2 1
      mirai-core/src/commonMain/kotlin/network/auth/CoroutineOnDemandValueScope.kt

+ 2 - 1
mirai-core/src/commonMain/kotlin/network/auth/CoroutineOnDemandValueScope.kt

@@ -99,7 +99,7 @@ internal class CoroutineOnDemandValueScope<T, V>(
     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<T, V>(
                     }
                     return null
                 }
+
                 else -> throw IllegalProducerStateException(state)
             }
         }