Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8229171

(zipfs) Closing a ZIP file system changes the zip file permissions

    XMLWordPrintable

Details

    • x86_64
    • linux

    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


      Attachments

        Issue Links

          Activity

            People

              lancea Lance Andersen
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: