-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
The following program never stops:
import zio.{ZIO, URIO, ExitCode}
object Main extends zio.App {
def program: ZIO[zio.ZEnv, Throwable, Any] =
// make sure that shutdown hook is registered
zio.clock.sleep(java.time.Duration.ofSeconds(2)) *> ZIO.effect(throw new OutOfMemoryError())
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = program.exitCode
}
I suppose that JVM just waits for that shutdown hook to finish its work (but it never happens):
zio/core/jvm/src/main/scala/zio/App.scala
Lines 57 to 61 in 2200981
| _ <- IO.effectTotal(java.lang.Runtime.getRuntime.addShutdownHook(new Thread { | |
| override def run() = { | |
| val _ = unsafeRunSync(fiber.interrupt) | |
| } | |
| })) |
Could it be that the fiber in which a fatal error was thrown just cannot be interrupted? If so then it explains why the shutdown hook blocks indefinitely.
P.S.
For some reason it looks like the code finishes normally when run with sbt (sbt 1.4.9 prints that the program has completed and then just freezes). However, if the compiled jars are invoked directly with java then the program never stops just as I described.
ZIO 1.0.5
openjdk 11.0.10
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working