Verify config saves survive cancellation of their submitting scope

This commit is contained in:
evgeny committed 2026-10-27 17:35:26 +01:00
1 parent 44f6d8a5bc
commit 02ec6a50a5
2 files changed
+13 -4

No files matched your search

@@ -9,6 +9,7 @@ import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicInteger
import java.util.concurrent.atomic.AtomicReference
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
@@ -52,8 +53,11 @@ class ConfigFileStoreTest {
val first = store.submit("blocked") { entered.countDown(); check(release.await(2, TimeUnit.SECONDS)) }
try {
assertTrue(entered.await(2, TimeUnit.SECONDS))
val save = store.submit("save") { replace(file, "complete") }
val screen = launch(start = CoroutineStart.UNDISPATCHED) { save.await() }
lateinit var save: Deferred<Unit>
val screen = launch(start = CoroutineStart.UNDISPATCHED) {
save = store.submit("save") { replace(file, "complete") }
save.await()
}
screen.cancelAndJoin()
assertFalse(save.isCancelled)
release.countDown()