@@ -22,13 +22,13 @@ import io.mockk.coVerify
2222import io.mockk.mockk
2323import java.util.concurrent.ConcurrentHashMap
2424import java.util.concurrent.ConcurrentMap
25+ import java.util.concurrent.Executors
2526import kotlin.test.assertFailsWith
2627import kotlin.test.assertFalse
2728import kotlinx.coroutines.CancellationException
2829import kotlinx.coroutines.CompletableDeferred
2930import kotlinx.coroutines.CoroutineScope
3031import kotlinx.coroutines.Deferred
31- import kotlinx.coroutines.Dispatchers
3232import kotlinx.coroutines.ExperimentalCoroutinesApi
3333import kotlinx.coroutines.SupervisorJob
3434import kotlinx.coroutines.asCoroutineDispatcher
@@ -42,7 +42,6 @@ import kotlinx.coroutines.test.runTest
4242import org.junit.Assert.assertEquals
4343import org.junit.Assert.assertTrue
4444import org.junit.Test
45- import java.util.concurrent.Executors
4645
4746@OptIn(ExperimentalCoroutinesApi ::class )
4847class StreamSingleFlightProcessorImplTest {
@@ -423,28 +422,31 @@ class StreamSingleFlightProcessorImplTest {
423422 val pool = Executors .newFixedThreadPool(4 ).asCoroutineDispatcher()
424423 try {
425424 val map = RecordingMap <Any , Deferred <Result <* >>>()
426- val sf = StreamSingleFlightProcessorImpl (
427- scope = CoroutineScope (SupervisorJob () + pool),
428- flights = map,
429- )
425+ val sf =
426+ StreamSingleFlightProcessorImpl (
427+ scope = CoroutineScope (SupervisorJob () + pool),
428+ flights = map,
429+ )
430430 val key = " k" .asStreamTypedKey<Int >()
431431
432432 repeat(200 ) { // more attempts to guarantee at least one race
433433 val gate = java.util.concurrent.CountDownLatch (1 )
434- val a = async(pool) {
435- gate.await()
436- sf.run (key) {
437- delay(100 ) // keep the winner running long enough
438- 1
434+ val a =
435+ async(pool) {
436+ gate.await()
437+ sf.run (key) {
438+ delay(100 ) // keep the winner running long enough
439+ 1
440+ }
439441 }
440- }
441- val b = async(pool) {
442- gate.await()
443- sf.run (key) {
444- delay(100 )
445- 1
442+ val b =
443+ async(pool) {
444+ gate.await()
445+ sf.run (key) {
446+ delay(100 )
447+ 1
448+ }
446449 }
447- }
448450 gate.countDown()
449451 a.await()
450452 b.await()
0 commit comments