Skip to content

Commit

Permalink
Fix race in testOnSendCancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
qwwdfsad committed Oct 4, 2021
1 parent 9c516a0 commit c806d9e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions reactive/kotlinx-coroutines-reactive/test/PublishTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,10 @@ class PublishTest : TestBase() {
expect(2)
// Collector is ready
send(1)
expect(3)
try {
send(2)
expectUnreached()
} catch (e: CancellationException) {
expect(7)
// publisher cancellation is async
latch.countDown()
throw e
Expand All @@ -312,15 +310,14 @@ class PublishTest : TestBase() {
val collectorLatch = Mutex(true)
val job = launch {
published.asFlow().buffer(0).collect {
expect(4)
collectorLatch.unlock()
hang { expect(6) }
hang { expect(4) }
}
}
collectorLatch.lock()
expect(5)
expect(3)
job.cancelAndJoin()
latch.await()
finish(8)
finish(5)
}
}

0 comments on commit c806d9e

Please sign in to comment.