A race condition can occur when shutting down the JVM. In that case, the VFSMountManagerHelper shutdown hook can execute concurrently with VFSMountManagerHelper.closeFileSystems. In that case, the vfsManager(VFS:DefaultFileSystemManager) can be closed by the shutdown hook and used later in the closeFileSystems method
This fix is meant to avoid such conflicting states by the following:
shutdown hook now calls the terminate method which is synchronized.
this terminate method nullifies the vfsManager field.
the closeFileSystems method does nothing if the VFSMountManagerHelper is already terminated.
The VFSMountManagerHelper can still be reused if a new call to mountAny is done, which regenerates the helper.
Added a test to verify that, after the terminate call, the closeFileSystems does not throw a NPE, and the helper can be regenerated with a call to mountAny
A race condition can occur when shutting down the JVM. In that case, the VFSMountManagerHelper shutdown hook can execute concurrently with VFSMountManagerHelper.closeFileSystems. In that case, the vfsManager(VFS:DefaultFileSystemManager) can be closed by the shutdown hook and used later in the closeFileSystems method
This fix is meant to avoid such conflicting states by the following:
Added a test to verify that, after the terminate call, the closeFileSystems does not throw a NPE, and the helper can be regenerated with a call to mountAny