Skip to content

Commit eac92c0

Browse files
authored
Fix a flaky test (#4227)
1 parent cf4fcd1 commit eac92c0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

kotlinx-coroutines-core/jvm/test/JobChildStressTest.kt

+8-4
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,14 @@ class JobChildStressTest : TestBase() {
8989
launch(pool + deferred) {
9090
deferred.complete(Unit) // Transition deferred into "completing" state waiting for current child
9191
// **Asynchronously** submit task that launches a child so it races with completion
92-
pool.executor.execute {
93-
rogueJob.set(launch(pool + deferred) {
94-
throw TestException("isCancelled: ${coroutineContext.job.isCancelled}")
95-
})
92+
try {
93+
pool.executor.execute {
94+
rogueJob.set(launch(pool + deferred) {
95+
throw TestException("isCancelled: ${coroutineContext.job.isCancelled}")
96+
})
97+
}
98+
} catch (_: RejectedExecutionException) {
99+
// This is expected if the pool is closed
96100
}
97101
}
98102

0 commit comments

Comments
 (0)