diff --git a/kotlinx-coroutines-core/jvm/src/DefaultExecutor.kt b/kotlinx-coroutines-core/jvm/src/DefaultExecutor.kt index 1b14748041..c993bc2324 100644 --- a/kotlinx-coroutines-core/jvm/src/DefaultExecutor.kt +++ b/kotlinx-coroutines-core/jvm/src/DefaultExecutor.kt @@ -8,7 +8,7 @@ import kotlinx.coroutines.internal.* import java.util.concurrent.* import kotlin.coroutines.* -private val defaultMainDelayOptIn = systemProp("kotlinx.coroutines.main.delay", true) +private val defaultMainDelayOptIn = systemProp("kotlinx.coroutines.main.delay", false) internal actual val DefaultDelay: Delay = initializeDefaultDelay() diff --git a/ui/kotlinx-coroutines-android/test/HandlerDispatcherTest.kt b/ui/kotlinx-coroutines-android/test/HandlerDispatcherTest.kt index 3c40c04b1e..af17adfc00 100644 --- a/ui/kotlinx-coroutines-android/test/HandlerDispatcherTest.kt +++ b/ui/kotlinx-coroutines-android/test/HandlerDispatcherTest.kt @@ -163,20 +163,19 @@ class HandlerDispatcherTest : TestBase() { } @Test - fun testDelayIsDelegatedToMain() = runTest { + fun testDelayIsNotDelegatedToMain() = runTest { val mainLooper = shadowOf(Looper.getMainLooper()) mainLooper.pause() val mainMessageQueue = shadowOf(Looper.getMainLooper().queue) assertNull(mainMessageQueue.head) val job = launch(Dispatchers.Default, start = CoroutineStart.UNDISPATCHED) { expect(1) - delay(10_000_000) - expect(3) + delay(Long.MAX_VALUE) + expectUnreached() } expect(2) - assertNotNull(mainMessageQueue.head) - mainLooper.runOneTask() - job.join() - finish(4) + assertNull(mainMessageQueue.head) + job.cancelAndJoin() + finish(3) } }