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

ZipPath does not relativize paths directly below the root correctly.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 8u65
    • core-libs
    • x86
    • os_x

      FULL PRODUCT VERSION :
      java version "1.8.0_65"
      Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
      Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Darwin Maxwells-MacBook-Air 15.2.0 Darwin Kernel Version 15.2.0: Fri Nov 13 19:56:56 PST 2015; root:xnu-3248.20.55~2/RELEASE_X86_64 x86_64

      A DESCRIPTION OF THE PROBLEM :
      Zip Paths on a Zip File System do not relativize correctly when the path is one level below root.

      E.g. "/test/".relativize("/test/me") => "../test/me" (incorrect)

      "/test/inner/".relativize("/test/inner/me") => "me" (correct)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      To reproduce this create a zip file somewhere on the file system.

      URI uri = URI.create("jar:file:/path/to/the.zip");
      FileSystem zipFs = FileSystems.newFileSystem(uri, Collections.emptyMap());
      zipFs.getPath("/test/").relativize(zipFs.getPath("/test/inner")).toString()

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      (com.sun.nio.zipfs.ZipPath) inner
      ACTUAL -
      (com.sun.nio.zipfs.ZipPath) ../test/inner

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
          public static void main(String[] args) throws IOException {
              URI uri = URI.create("jar:file:/path/to/the/test.zip");
              FileSystem zipFs = FileSystems.newFileSystem(uri, Collections.emptyMap());
              System.out.println(zipFs.getPath("/test/").relativize(zipFs.getPath("/test/inner")));
          }
      ---------- END SOURCE ----------

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: