diff --git a/kotlinx-coroutines-core/jvm/test/JobChildStressTest.kt b/kotlinx-coroutines-core/jvm/test/JobChildStressTest.kt index a30e6393b6..46b7ee790a 100644 --- a/kotlinx-coroutines-core/jvm/test/JobChildStressTest.kt +++ b/kotlinx-coroutines-core/jvm/test/JobChildStressTest.kt @@ -89,10 +89,14 @@ class JobChildStressTest : TestBase() { launch(pool + deferred) { deferred.complete(Unit) // Transition deferred into "completing" state waiting for current child // **Asynchronously** submit task that launches a child so it races with completion - pool.executor.execute { - rogueJob.set(launch(pool + deferred) { - throw TestException("isCancelled: ${coroutineContext.job.isCancelled}") - }) + try { + pool.executor.execute { + rogueJob.set(launch(pool + deferred) { + throw TestException("isCancelled: ${coroutineContext.job.isCancelled}") + }) + } + } catch (_: RejectedExecutionException) { + // This is expected if the pool is closed } }