thrau / jarchivelib

A simple archiving and compression library for Java
https://github.com/thrau/jarchivelib
Apache License 2.0
198 stars 36 forks source link

File mode permission throwing exception in JDK10 and 11 #70

Closed robin-anil closed 5 years ago

robin-anil commented 5 years ago
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.rauschig.jarchivelib.FileModeMapper$FileSystemPreferencesReflectionChmodCommand.chmod(FileModeMapper.java:144)
    at org.rauschig.jarchivelib.FileModeMapper$UnixPermissionMapper.chmod(FileModeMapper.java:119)
    at org.rauschig.jarchivelib.FileModeMapper$UnixPermissionMapper.map(FileModeMapper.java:105)
    at org.rauschig.jarchivelib.FileModeMapper.map(FileModeMapper.java:53)
    at org.rauschig.jarchivelib.CommonsArchiver.extract(CommonsArchiver.java:106)
    at org.rauschig.jarchivelib.CommonsArchiver.extract(CommonsArchiver.java:81)
    at pl.allegro.tech.embeddedelasticsearch.ElasticSearchInstaller.unzip(ElasticSearchInstaller.java:76)
Caused by: java.lang.UnsatisfiedLinkError: java.util.prefs.FileSystemPreferences.chmod(Ljava/lang/String;I)I
    at java.prefs/java.util.prefs.FileSystemPreferences.chmod(Native Method)
cliffcotino commented 5 years ago

We are encountering the same issue (also due to our use of the embedded-elasticsearch plugin) We can also reproduce the situation in this library by running mvn clean build with JDK 11.

It seems to me that a fix could be to use java.nio to set file permissions instead.

I would be glad to provide to provide pull requests. Maybe something based on https://github.com/thrau/jarchivelib/pull/66?

cliffcotino commented 5 years ago

I created a pull request that runs on JDK versions >= 9 Pull request: https://github.com/thrau/jarchivelib/pull/72

thrau commented 5 years ago

fixed with #72