JDK-8229171 : (zipfs) Closing a ZIP file system changes the zip file permissions
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 8,11,13
  • Priority: P4
  • Status: Resolved
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86_64
  • Submitted: 2019-08-05
  • Updated: 2019-12-18
  • Resolved: 2019-12-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE PROBLEM :
I don't think there is a better way to describe the problem better than the code itself.
Let's assume we have "comment.zip" with permissions "-rw-rw-r--" on Desktop, the code will change the permissions to "-rw-------"

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just run the code.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Zip file permissions shouldn't change.
ACTUAL -
Zip file permissions change to "-rw-------"

---------- BEGIN SOURCE ----------
String zipPath = "/home/ahashem/Desktop/comment.zip";
    URI uri = URI.create("jar:file:" + zipPath);
    try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.singletonMap("create", "true"))) {
        Path pathInZipFile = fs.getPath("comment.txt");
        Files.copy(Paths.get("/home/ahashem/Desktop/comment.txt"), pathInZipFile, StandardCopyOption.REPLACE_EXISTING);
    }
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
String zipPath = "/home/ahashem/Desktop/comment.zip";
    URI uri = URI.create("jar:file:" + zipPath);
    Set<PosixFilePermission> defaultPermissions = Files.getPosixFilePermissions(Paths.get(zipPath));
    try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.singletonMap("create", "true"))) {
        Path pathInZipFile = fs.getPath("comment.txt");
        Files.copy(Paths.get("/home/ahashem/Desktop/comment.txt"), pathInZipFile, StandardCopyOption.REPLACE_EXISTING);
    }
    Files.setPosixFilePermissions(Paths.get(zipPath), defaultPermissions);

FREQUENCY : always



Comments
This issue is the same as JDK-8229888
18-12-2019

To reproduce the issue, run the attached test case : JDK 8u212 - Fail JDK 11.0.3 - Fail JDK 13-ea+30 - Fail Before running test case : dcsuser@dcsuser-VirtualBox:~/Desktop$ ls -l total 8 -rw-r--r-- 1 dcsuser dcsuser 0 Aug 6 04:34 comment.txt -rw-r--r-- 1 dcsuser dcsuser 22 Aug 6 04:34 comment.zip -rwxr-xr-x 1 dcsuser dcsuser 273 Oct 22 2018 netbeans-8.2.desktop After running test case : dcsuser@dcsuser-VirtualBox:~/Desktop$ ls -l total 8 -rw-r--r-- 1 dcsuser dcsuser 0 Aug 6 04:34 comment.txt -rw------- 1 dcsuser dcsuser 164 Aug 6 04:34 comment.zip -rwxr-xr-x 1 dcsuser dcsuser 273 Oct 22 2018 netbeans-8.2.desktop
06-08-2019