8263940: NPE when creating default file system when default file system provider is packaged as JAR file on class path

Reviewed-by: naoto, bpb, iris, joehw
This commit is contained in:
Lance Andersen 2021-08-13 16:11:04 +00:00
parent d06d0b9e9d
commit 717792c3b7
2 changed files with 53 additions and 6 deletions

View file

@ -33,7 +33,6 @@ import java.io.File;
import java.io.RandomAccessFile;
import java.io.UncheckedIOException;
import java.lang.ref.Cleaner.Cleanable;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.file.InvalidPathException;
import java.nio.file.attribute.BasicFileAttributes;
@ -69,6 +68,7 @@ import jdk.internal.perf.PerfCounter;
import jdk.internal.ref.CleanerFactory;
import jdk.internal.vm.annotation.Stable;
import sun.nio.cs.UTF_8;
import sun.nio.fs.DefaultFileSystemProvider;
import sun.security.util.SignatureFileVerifier;
import static java.util.zip.ZipConstants64.*;
@ -1255,14 +1255,19 @@ public class ZipFile implements ZipConstants, Closeable {
}
}
private static final HashMap<Key, Source> files = new HashMap<>();
/**
* Use the platform's default file system to avoid
* issues when the VM is configured to use a custom file system provider.
*/
private static final java.nio.file.FileSystem builtInFS =
DefaultFileSystemProvider.theFileSystem();
static Source get(File file, boolean toDelete, ZipCoder zc) throws IOException {
final Key key;
try {
key = new Key(file,
Files.readAttributes(file.toPath(), BasicFileAttributes.class),
zc);
Files.readAttributes(builtInFS.getPath(file.getPath()),
BasicFileAttributes.class), zc);
} catch (InvalidPathException ipe) {
throw new IOException(ipe);
}