Skip to content

Commit

Permalink
Fix spurious failures in TaskTest (Kotlin#2996)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwwdfsad authored and pablobaxter committed Sep 14, 2022
1 parent 0958e66 commit 015928d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
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

0 comments on commit 015928d

Please sign in to comment.