-
Bug
-
Resolution: Unresolved
-
P4
-
12
-
x86_64
-
windows_10
ADDITIONAL SYSTEM INFORMATION :
Windows with access to an UNC share. The bug was originally found in 8, and is still present in Java 12.
A DESCRIPTION OF THE PROBLEM :
When creating a zip file on a remote directory with the code below,
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
In Windows, run the program below with a file name that points to a file which would be on a remote directory, either an UNC path (like \\server\share\foo.zip) or a drive letter that maps to a share.
You can call the program with a local path to see that the code is working.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
ZIP file is created with a zip entry inside.
ACTUAL -
Exception in thread "main" java.nio.file.ReadOnlyFileSystemException
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.checkWritable(ZipFileSystem.java:158)
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.newOutputStream(ZipFileSystem.java:519)
at jdk.zipfs/jdk.nio.zipfs.ZipPath.newOutputStream(ZipPath.java:848)
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.newOutputStream(ZipFileSystemProvider.java:280)
at java.base/java.nio.file.Files.newOutputStream(Files.java:222)
at ZipFileSystemTest.main(ZipFileSystemTest.java:14)
---------- BEGIN SOURCE ----------
import java.net.URI;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.HashMap;
import java.util.Map;
public class ZipFileSystemTest {
public static void main(String[] args) throws Exception {
final Map<String, Object> env = new HashMap<>();
env.put("create", "true");
Files.newOutputStream(FileSystems.newFileSystem(URI.create("jar:" + Paths.get(args[0]).toUri()), env).getPath("entry"),
StandardOpenOption.CREATE_NEW);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
You can avoid the problem by switching the readOnly private member of ZipFileSystem to true via reflection (tested in Java 8).
FREQUENCY : always
Windows with access to an UNC share. The bug was originally found in 8, and is still present in Java 12.
A DESCRIPTION OF THE PROBLEM :
When creating a zip file on a remote directory with the code below,
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
In Windows, run the program below with a file name that points to a file which would be on a remote directory, either an UNC path (like \\server\share\foo.zip) or a drive letter that maps to a share.
You can call the program with a local path to see that the code is working.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
ZIP file is created with a zip entry inside.
ACTUAL -
Exception in thread "main" java.nio.file.ReadOnlyFileSystemException
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.checkWritable(ZipFileSystem.java:158)
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.newOutputStream(ZipFileSystem.java:519)
at jdk.zipfs/jdk.nio.zipfs.ZipPath.newOutputStream(ZipPath.java:848)
at jdk.zipfs/jdk.nio.zipfs.ZipFileSystemProvider.newOutputStream(ZipFileSystemProvider.java:280)
at java.base/java.nio.file.Files.newOutputStream(Files.java:222)
at ZipFileSystemTest.main(ZipFileSystemTest.java:14)
---------- BEGIN SOURCE ----------
import java.net.URI;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.HashMap;
import java.util.Map;
public class ZipFileSystemTest {
public static void main(String[] args) throws Exception {
final Map<String, Object> env = new HashMap<>();
env.put("create", "true");
Files.newOutputStream(FileSystems.newFileSystem(URI.create("jar:" + Paths.get(args[0]).toUri()), env).getPath("entry"),
StandardOpenOption.CREATE_NEW);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
You can avoid the problem by switching the readOnly private member of ZipFileSystem to true via reflection (tested in Java 8).
FREQUENCY : always