You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Since 1.7.0, CoroutineDispatcher isActive is still true after cancel()
Provide a Reproducer
@Test
fun dispatcherIsNotActiveAfterCancellation() = runTest {
val dispatcher = Dispatchers.Default // same for UnconfinedTestDispatcher or any other
dispatcher.cancel()
assertFalse(dispatcher.isActive)
}
org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4 - test passes org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.0 - AssertionError (same for v1.7.3, which is currently the latest stable)
The text was updated successfully, but these errors were encountered:
CoroutineDispather.cancel() is a call that does not make sense here: it resolves to CoroutineContext.cancel() (because every CoroutineContext.Element is a CoroutineContext itself).
The call checks for a Job in the context and cancels it if it's present. A dispatcher never has a Job (at least not the dispatchers shipped with the library, not sure if they even can have a Job).
The behavior change stems from #3300: isActive now returns true when a job is not present in context.
Describe the bug
Since 1.7.0, CoroutineDispatcher
isActive
is stilltrue
aftercancel()
Provide a Reproducer
org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4
- test passesorg.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.0
- AssertionError (same for v1.7.3, which is currently the latest stable)The text was updated successfully, but these errors were encountered: