ZipFileStore#supportsFileAttributeView(String) doesn't throw NPE
Andrey Turbanov
turbanoff at gmail.com
Tue Jan 10 09:35:04 UTC 2023
Hello.
I've noticed that ZipFileStore#supportsFileAttributeView(String)
doesn't throw NullPointerException when 'null' is passed as an
argument.
public boolean supportsFileAttributeView(String name) {
return "basic".equals(name) || "zip".equals(name) ||
(("owner".equals(name) || "posix".equals(name)) && zfs.supportPosix);
}
Method body was changed to not throw NPE in JDK-8213031.
I wonder if it was an intentional change or not?
My reproducer shows difference between ZipFileStore and WindowsFileStore
public static void main(String[] args) throws IOException {
checkFsForNull(FileSystems.newFileSystem(Path.of("D:\\config.zip")));
checkFsForNull(FileSystems.getDefault());
}
private static void checkFsForNull(FileSystem fs) {
fs.getFileStores().iterator().next().supportsFileAttributeView((String)null);
}
Andrey Turbanov
More information about the core-libs-dev
mailing list