terl / lazysodium-java

A Java implementation of the Libsodium crypto library. For the lazy dev.
https://github.com/terl/lazysodium-java/wiki
Mozilla Public License 2.0
134 stars 46 forks source link

Bundled sodium.dll cannot be loaded when path to JAR contains spaces #120

Open tomwetjens opened 1 year ago

tomwetjens commented 1 year ago

When running LazySodium on Windows, the bundled sodium.dll cannot be loaded when the path to the lazysodium JAR file contains spaces:

Native library (win32-x86-64/sodium.dll) not found in resource path (C:\Users\Tom Wetjens\.m2\repository\org\junit\platform\junit-platform-launcher\1.8.2\junit-platform-launcher-1.8.2.jar;...<cut long output>.
09:22:46.738 [main] DEBUG ResourceLoader - This is not a JAR file due to C:\Users\Tom%20Wetjens\.m2\repository\com\goterl\lazysodium-java\5.1.1\lazysodium-java-5.1.1.jar

java.nio.file.FileSystemNotFoundException
    at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:156)
    at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:142)
    at java.base/java.nio.file.Path.of(Path.java:208)
    at java.base/java.nio.file.Paths.get(Paths.java:98)
    at com.goterl.resourceloader.ResourceLoader.getFileFromFileSystem(ResourceLoader.java:237)
    at com.goterl.resourceloader.ResourceLoader.copyToTempDirectory(ResourceLoader.java:88)
    at com.goterl.resourceloader.SharedLibraryLoader.load(SharedLibraryLoader.java:53)
    at com.goterl.lazysodium.utils.LibraryLoader.loadBundledLibrary(LibraryLoader.java:134)
    at com.goterl.lazysodium.utils.LibraryLoader.loadLibrary(LibraryLoader.java:95)
    at com.goterl.lazysodium.SodiumJava.<init>(SodiumJava.java:34)
    at com.goterl.lazysodium.SodiumJava.<init>(SodiumJava.java:23)

After changing the local Maven repository to a path without spaces e.g. C:\maven\repository, loading of the bundled sodium.dll works fine.

It would be nice if it works on all platforms, regardless of spaces in the path.

tomwetjens commented 1 year ago

Seems to be caused by https://github.com/terl/resource-loader/pull/14