Skip to content

Fix spurious failures in TaskTest #2996

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion kotlinx-coroutines-core/jvm/src/DefaultExecutor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion kotlinx-coroutines-core/jvm/test/TestBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down