8325199: (zipfs) jdk/nio/zipfs/TestPosix.java failed 6 sub-tests

Reviewed-by: clanger, lancea
This commit is contained in:
Eirik Bjørsnøs 2024-02-05 17:59:59 +00:00
parent 1993652653
commit c3adc61e6e
2 changed files with 6 additions and 12 deletions

View File

@ -104,7 +104,6 @@ public class TestPosix {
// misc // misc
private static final CopyOption[] COPY_ATTRIBUTES = {StandardCopyOption.COPY_ATTRIBUTES}; private static final CopyOption[] COPY_ATTRIBUTES = {StandardCopyOption.COPY_ATTRIBUTES};
private static final Map<String, ZipFileEntryInfo> ENTRIES = new HashMap<>(); private static final Map<String, ZipFileEntryInfo> ENTRIES = new HashMap<>();
private static final boolean isWindows = System.getProperty("os.name") .startsWith("Windows");
private int entriesCreated; private int entriesCreated;
@ -292,7 +291,8 @@ public class TestPosix {
return fs; return fs;
} }
private FileSystem createEmptyZipFile(Path zpath, Map<String, Object> env) throws IOException { // The caller is responsible for closing the FileSystem returned by this method
private FileSystem createEmptyZipFileSystem(Path zpath, Map<String, Object> env) throws IOException {
if (Files.exists(zpath)) { if (Files.exists(zpath)) {
System.out.println("Deleting old " + zpath + "..."); System.out.println("Deleting old " + zpath + "...");
Files.delete(zpath); Files.delete(zpath);
@ -481,7 +481,7 @@ public class TestPosix {
public void testCopy() throws IOException { public void testCopy() throws IOException {
// copy zip to zip with default options // copy zip to zip with default options
try (FileSystem zipIn = createTestZipFile(ZIP_FILE, ENV_DEFAULT); try (FileSystem zipIn = createTestZipFile(ZIP_FILE, ENV_DEFAULT);
FileSystem zipOut = createEmptyZipFile(ZIP_FILE_COPY, ENV_DEFAULT)) { FileSystem zipOut = createEmptyZipFileSystem(ZIP_FILE_COPY, ENV_DEFAULT)) {
Path from = zipIn.getPath("/"); Path from = zipIn.getPath("/");
Files.walkFileTree(from, new CopyVisitor(from, zipOut.getPath("/"))); Files.walkFileTree(from, new CopyVisitor(from, zipOut.getPath("/")));
} }
@ -517,7 +517,7 @@ public class TestPosix {
// the target zip file is opened with Posix support // the target zip file is opened with Posix support
// but we expect no permission data to be copied using the default copy method // but we expect no permission data to be copied using the default copy method
try (FileSystem tgtZip = createEmptyZipFile(ZIP_FILE_COPY, ENV_POSIX)) { try (FileSystem tgtZip = createEmptyZipFileSystem(ZIP_FILE_COPY, ENV_POSIX)) {
Files.walkFileTree(UNZIP_DIR, new CopyVisitor(UNZIP_DIR, tgtZip.getPath("/"))); Files.walkFileTree(UNZIP_DIR, new CopyVisitor(UNZIP_DIR, tgtZip.getPath("/")));
} }
@ -560,7 +560,7 @@ public class TestPosix {
// permissions should have been propagated to file system // permissions should have been propagated to file system
checkEntries(UNZIP_DIR, checkExpects.permsPosix); checkEntries(UNZIP_DIR, checkExpects.permsPosix);
try (FileSystem tgtZip = createEmptyZipFile(ZIP_FILE_COPY, ENV_POSIX)) { try (FileSystem tgtZip = createEmptyZipFileSystem(ZIP_FILE_COPY, ENV_POSIX)) {
// Make some files owner readable to be able to copy them into the zipfs // Make some files owner readable to be able to copy them into the zipfs
addOwnerRead(UNZIP_DIR); addOwnerRead(UNZIP_DIR);
@ -742,13 +742,8 @@ public class TestPosix {
*/ */
@Test @Test
public void setPermissionsShouldConvertToUnix() throws IOException { public void setPermissionsShouldConvertToUnix() throws IOException {
// Temporarily skip test on Windows until intermittent failures are investigated
if(isWindows) {
return;
}
// The default environment creates MS-DOS entries, with zero 'external file attributes' // The default environment creates MS-DOS entries, with zero 'external file attributes'
createEmptyZipFile(ZIP_FILE, ENV_DEFAULT); try (FileSystem fs = createEmptyZipFileSystem(ZIP_FILE, ENV_DEFAULT)) {
try (FileSystem fs = FileSystems.newFileSystem(ZIP_FILE, ENV_DEFAULT)) {
Path path = fs.getPath("hello.txt"); Path path = fs.getPath("hello.txt");
Files.createFile(path); Files.createFile(path);
} }

View File

@ -4,7 +4,6 @@ grant {
permission java.util.PropertyPermission "test.jdk","read"; permission java.util.PropertyPermission "test.jdk","read";
permission java.util.PropertyPermission "test.src","read"; permission java.util.PropertyPermission "test.src","read";
permission java.util.PropertyPermission "user.dir","read"; permission java.util.PropertyPermission "user.dir","read";
permission java.util.PropertyPermission "os.name","read";
permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.module"; permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.module";
permission java.lang.RuntimePermission "accessUserInformation"; permission java.lang.RuntimePermission "accessUserInformation";
}; };