Skip to content

Commit

Permalink
Update test.
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkloch committed Nov 12, 2024
1 parent 5c9d34c commit 59062c4
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions tests/jvm/src/test/scala/cats/effect/std/DispatcherJVMSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,21 @@ class DispatcherJVMSpec extends BaseSpec {
}

"Propagate Java thread interruption in unsafeRunSync" in real {
val res = Dispatcher.parallel[IO](await = true).evalMap { dispatcher =>
Dispatcher.parallel[IO](await = true).use { dispatcher =>
for {
canceled <- Deferred[IO, Unit]
io = IO.sleep(1.second).onCancel(canceled.complete(()).void)
thread = new Thread(() =>
f <- IO.interruptible {
try dispatcher.unsafeRunSync(io)
catch { case _: InterruptedException => })
_ <- IO(thread.start).as(thread)
catch { case _: InterruptedException => }
}.start
_ <- IO.sleep(100.millis)
_ <- IO(thread.interrupt())
_ <- IO(thread.join())
_ <- f.cancel
_ <- canceled
.get
.timeoutTo(300.millis, IO.raiseError(new Exception("io was not canceled")))
} yield ()
} yield ok
}

res.use(_ => IO(ok))
}
}
}

0 comments on commit 59062c4

Please sign in to comment.