The shutdown hook is therefore not only completely useless but even leads to errors, if the drives get unmounted (by a different, working shutdown hook) during program termination:
java.lang.IllegalStateException: Shutdown in progress
at java.base/java.lang.ApplicationShutdownHooks.add(ApplicationShutdownHooks.java:66)
at java.base/java.lang.Runtime.addShutdownHook(Runtime.java:215)
at com.dokany.java.DokanyDriver.start(DokanyDriver.java:68)
NativeMethods.DokanMain
is a blocking method, therefore the following code doesn't get invoked until the drive is unmounted:https://github.com/cryptomator/dokany-nio-adapter/blob/e4e24a9eebbae64088629a3292e470c15756ef43/src/main/java/com/dokany/java/DokanyDriver.java#L61-L74
The shutdown hook is therefore not only completely useless but even leads to errors, if the drives get unmounted (by a different, working shutdown hook) during program termination: