Skip to content

Commit 2487f75

Browse files
authored
Fix AwsResourceCacheTest#concurrentlyRunningExceptionalResourcesGetTheSameException (#3173)
1 parent 6373577 commit 2487f75

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

jetbrains-core/tst/software/aws/toolkits/jetbrains/core/AwsResourceCacheTest.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import com.intellij.openapi.application.ApplicationManager
77
import com.intellij.testFramework.ProjectRule
88
import com.intellij.testFramework.RuleChain
99
import kotlinx.coroutines.ExperimentalCoroutinesApi
10+
import kotlinx.coroutines.delay
1011
import kotlinx.coroutines.runBlocking
12+
import kotlinx.coroutines.test.runBlockingTest
1113
import org.assertj.core.api.Assertions.assertThat
1214
import org.assertj.core.api.Assertions.assertThatThrownBy
1315
import org.junit.Before
@@ -485,7 +487,11 @@ class AwsResourceCacheTest {
485487
fun concurrentlyRunningExceptionalResourcesGetTheSameException() {
486488
val latch = CountDownLatch(1)
487489
whenever(mockResource.fetch(any(), any())).then {
488-
latch.await(500, TimeUnit.MILLISECONDS)
490+
latch.await()
491+
// exception gets thrown fast enough where the second fetchIfNeeded check occurs after the first call throws
492+
runBlockingTest {
493+
delay(500)
494+
}
489495
throw RuntimeException("Boom")
490496
}
491497

0 commit comments

Comments
 (0)