diff --git a/integration/kotlinx-coroutines-play-services/test/FakeAndroid.kt b/integration/kotlinx-coroutines-play-services/test/FakeAndroid.kt index 6026ffd75d..e286ee197b 100644 --- a/integration/kotlinx-coroutines-play-services/test/FakeAndroid.kt +++ b/integration/kotlinx-coroutines-play-services/test/FakeAndroid.kt @@ -2,10 +2,17 @@ package android.os import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import java.util.concurrent.* class Handler(val looper: Looper) { fun post(r: Runnable): Boolean { - GlobalScope.launch { r.run() } + try { + GlobalScope.launch { r.run() } + } catch (e: RejectedExecutionException) { + // Execute leftover callbacks in place for tests + r.run() + } + return true } } diff --git a/kotlinx-coroutines-core/jvm/src/DefaultExecutor.kt b/kotlinx-coroutines-core/jvm/src/DefaultExecutor.kt index 2968825d15..6457d26e0a 100644 --- a/kotlinx-coroutines-core/jvm/src/DefaultExecutor.kt +++ b/kotlinx-coroutines-core/jvm/src/DefaultExecutor.kt @@ -42,7 +42,7 @@ internal actual object DefaultExecutor : EventLoopImplBase(), Runnable { @Volatile private var debugStatus: Int = FRESH - val isShutDown: Boolean get() = debugStatus == SHUTDOWN + private val isShutDown: Boolean get() = debugStatus == SHUTDOWN private val isShutdownRequested: Boolean get() { val debugStatus = debugStatus diff --git a/kotlinx-coroutines-core/jvm/test/TestBase.kt b/kotlinx-coroutines-core/jvm/test/TestBase.kt index fce8eff3c5..72a4a2cf2c 100644 --- a/kotlinx-coroutines-core/jvm/test/TestBase.kt +++ b/kotlinx-coroutines-core/jvm/test/TestBase.kt @@ -152,7 +152,8 @@ public actual open class TestBase(private var disableOutCheck: Boolean) { }) fun println(message: Any?) { - previousOut.println(message) + if (disableOutCheck) kotlin.io.println(message) + else previousOut.println(message) } @Before