cryptomator / dokany-nio-adapter

Dokany-based adapter to provide directory contents specified by a java.nio.file.Path (via dokan-java)
GNU Affero General Public License v3.0
14 stars 4 forks source link

Shutdown hook never invoked #34

Closed overheadhunter closed 4 years ago

overheadhunter commented 4 years ago

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:

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)