-
Bug
-
Resolution: Fixed
-
P3
-
7
-
b132
-
generic
-
generic
-
Verified
jdk version: jdk7-fcs-pit-b123
The following java code shows whatever the real file/dir a FileRef reprensents, FileSystems.newFileSystem(FileRef...) always try to use zipfs.
======Begin of code======
import java.io.IOException;
import java.nio.file.*;
import java.util.*;
public class test {
public static void main(String[] args) throws IOException {
try {
FileRef fref = Paths.get("text.txt");
Map<String, ?> env = Collections.emptyMap();
FileSystems.newFileSystem(fref, env, (ClassLoader) null);
} catch (Exception e) {
e.printStackTrace();
}
try {
FileRef fref = Paths.get(".");
Map<String, ?> env = Collections.emptyMap();
FileSystems.newFileSystem(fref, env, (ClassLoader) null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
======End of code======
output:
===============
java.nio.file.FileSystemNotFoundException: text.txt
at com.sun.nio.zipfs.ZipFileSystem.<init>(ZipFileSystem.java:112)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:116)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:103)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:394)
at test.main(test.java:10)
java.nio.file.AccessDeniedException: .
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsPath.newByteChannel(WindowsPath.java:1090)
at sun.nio.fs.AbstractPath.newByteChannel(AbstractPath.java:112)
at com.sun.nio.zipfs.ZipFileSystem.<init>(ZipFileSystem.java:123)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:116)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:103)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:394)
at test.main(test.java:18)
=============
While using zipfs to handle non-zip regular file might be correct (at least for now, with no other fs providers to handle other types of file), a dir should not be handled by zipfs (and any other future file-type specific fs providers)
The following java code shows whatever the real file/dir a FileRef reprensents, FileSystems.newFileSystem(FileRef...) always try to use zipfs.
======Begin of code======
import java.io.IOException;
import java.nio.file.*;
import java.util.*;
public class test {
public static void main(String[] args) throws IOException {
try {
FileRef fref = Paths.get("text.txt");
Map<String, ?> env = Collections.emptyMap();
FileSystems.newFileSystem(fref, env, (ClassLoader) null);
} catch (Exception e) {
e.printStackTrace();
}
try {
FileRef fref = Paths.get(".");
Map<String, ?> env = Collections.emptyMap();
FileSystems.newFileSystem(fref, env, (ClassLoader) null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
======End of code======
output:
===============
java.nio.file.FileSystemNotFoundException: text.txt
at com.sun.nio.zipfs.ZipFileSystem.<init>(ZipFileSystem.java:112)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:116)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:103)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:394)
at test.main(test.java:10)
java.nio.file.AccessDeniedException: .
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsPath.newByteChannel(WindowsPath.java:1090)
at sun.nio.fs.AbstractPath.newByteChannel(AbstractPath.java:112)
at com.sun.nio.zipfs.ZipFileSystem.<init>(ZipFileSystem.java:123)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:116)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:103)
at java.nio.file.FileSystems.newFileSystem(FileSystems.java:394)
at test.main(test.java:18)
=============
While using zipfs to handle non-zip regular file might be correct (at least for now, with no other fs providers to handle other types of file), a dir should not be handled by zipfs (and any other future file-type specific fs providers)