Skip to content

Commit 75015cd

Browse files
qwwdfsadyorickhenning
authored andcommitted
Fix spurious failures in TaskTest (Kotlin#2996)
1 parent 7e6ff2a commit 75015cd

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

integration/kotlinx-coroutines-play-services/test/FakeAndroid.kt

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@ package android.os
22

33
import kotlinx.coroutines.GlobalScope
44
import kotlinx.coroutines.launch
5+
import java.util.concurrent.*
56

67
class Handler(val looper: Looper) {
78
fun post(r: Runnable): Boolean {
8-
GlobalScope.launch { r.run() }
9+
try {
10+
GlobalScope.launch { r.run() }
11+
} catch (e: RejectedExecutionException) {
12+
// Execute leftover callbacks in place for tests
13+
r.run()
14+
}
15+
916
return true
1017
}
1118
}

kotlinx-coroutines-core/jvm/src/DefaultExecutor.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ internal actual object DefaultExecutor : EventLoopImplBase(), Runnable {
4242
@Volatile
4343
private var debugStatus: Int = FRESH
4444

45-
val isShutDown: Boolean get() = debugStatus == SHUTDOWN
45+
private val isShutDown: Boolean get() = debugStatus == SHUTDOWN
4646

4747
private val isShutdownRequested: Boolean get() {
4848
val debugStatus = debugStatus

kotlinx-coroutines-core/jvm/test/TestBase.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ public actual open class TestBase(private var disableOutCheck: Boolean) {
152152
})
153153

154154
fun println(message: Any?) {
155-
previousOut.println(message)
155+
if (disableOutCheck) kotlin.io.println(message)
156+
else previousOut.println(message)
156157
}
157158

158159
@Before

0 commit comments

Comments
 (0)