From e3023fe03718afd0bd812f43ce1c42622bfee348 Mon Sep 17 00:00:00 2001 From: Ivan Semenov Date: Thu, 26 Oct 2023 18:36:04 +0200 Subject: [PATCH] [collab] fix test waiting for scope to finish forever GitOrigin-RevId: 740a2a68e92e7f2208f9890531ca9ad58a0383e1 --- .../auth/AccountUrlAuthenticationFailuresHolder.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/collaboration-tools/src/com/intellij/collaboration/auth/AccountUrlAuthenticationFailuresHolder.kt b/platform/collaboration-tools/src/com/intellij/collaboration/auth/AccountUrlAuthenticationFailuresHolder.kt index b1bbc783b0b1..030d15ae0ef8 100644 --- a/platform/collaboration-tools/src/com/intellij/collaboration/auth/AccountUrlAuthenticationFailuresHolder.kt +++ b/platform/collaboration-tools/src/com/intellij/collaboration/auth/AccountUrlAuthenticationFailuresHolder.kt @@ -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( private val storeMap = ConcurrentHashMap>() 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) }