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

(zipfs) ZipFileSystemProvider rejects paths containing spaces

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4
    • tbd
    • 7
    • core-libs
    • x86
    • windows_7

    Description

      FULL PRODUCT VERSION :
      java version "1.7.0"
      Java(TM) SE Runtime Environment (build 1.7.0-b147)
      Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      Paths.get() depends on ZipFileSystemProvider for paths inside JAR files.

      Paths.get(uriWithSpaces) works in the default filesystem, but throws "java.lang.IllegalArgumentException: Illegal character in path" for ZipFileSystemProvider.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run testcase

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Testcase should run without throwing exceptions
      ACTUAL -
      Testcase throws:

      Exception in thread "main" java.lang.IllegalArgumentException: Illegal character in path at index 16: file:/C:/Program Files/Internet Explorer
      at com.sun.nio.zipfs.ZipFileSystemProvider.uriToPath(ZipFileSystemProvider.java:78)
      at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:157)
      at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:148)
      at java.nio.file.Paths.get(Paths.java:143)
      at com.mycompany.mavenproject3.App.main(App.java:22)
      Caused by: java.net.URISyntaxException: Illegal character in path at index 16: file:/C:/Program Files/Internet Explorer
      at java.net.URI$Parser.fail(URI.java:2827)
      at java.net.URI$Parser.checkChars(URI.java:3000)
      at java.net.URI$Parser.parseHierarchical(URI.java:3084)
      at java.net.URI$Parser.parse(URI.java:3032)
      at java.net.URI.<init>(URI.java:595)
      at com.sun.nio.zipfs.ZipFileSystemProvider.uriToPath(ZipFileSystemProvider.java:76)
      ... 4 more

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.net.MalformedURLException;
      import java.net.URI;
      import java.net.URISyntaxException;
      import java.net.URL;
      import java.nio.file.Path;
      import java.nio.file.Paths;

      public class App
      {
          public static void main( String[] args ) throws URISyntaxException, MalformedURLException
          {
              URL url = new URL("jar:file:/C:/Program%20Files/Internet%20Explorer!/nonExistent");
              System.out.println("valid url: " + url);
              URI uri = url.toURI();
              System.out.println("valid uri: " + url);
              Path path = Paths.get(uri); // exception thrown
              System.out.println("valid path: " + path);
          }
      }

      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              sherman Xueming Shen
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: