JDK-7108548 : (zipfs) ZipFileSystemProvider rejects paths containing spaces
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86
  • Submitted: 2011-11-04
  • Updated: 2012-04-12
  • Resolved: 2012-04-12
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
tbd_minorResolved
Related Reports
Duplicate :  
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 ----------