[collab] fix test waiting for scope to finish forever

GitOrigin-RevId: 740a2a68e92e7f2208f9890531ca9ad58a0383e1
This commit is contained in:
Ivan Semenov
2023-10-26 18:36:04 +02:00
committed by intellij-monorepo-bot
parent b627df99b7
commit e3023fe037

View File

@@ -2,8 +2,9 @@
package com.intellij.collaboration.auth
import com.intellij.concurrency.ConcurrentCollectionFactory
import com.intellij.util.awaitCancellationAndInvoke
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import java.util.concurrent.ConcurrentHashMap
@@ -15,14 +16,14 @@ class AccountUrlAuthenticationFailuresHolder<A : Account>(
private val storeMap = ConcurrentHashMap<A, MutableSet<String>>()
init {
cs.awaitCancellationAndInvoke {
cs.coroutineContext[Job]?.invokeOnCompletion {
storeMap.clear()
}
}
fun markFailed(account: A, url: String) {
storeMap.computeIfAbsent(account) {
cs.launch {
cs.launch(CoroutineName("AccountUrlAuthenticationFailuresHolder token change listener")) {
accountManager().getCredentialsFlow(account).first()
storeMap.remove(account)
}