RFR: 8350880: (zipfs) Add support for read-only zip file systems [v6]

David Beaumont duke at openjdk.org
Mon May 19 14:04:09 UTC 2025


On Mon, 19 May 2025 12:54:37 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> David Beaumont has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Fixed test.
>
> test/jdk/jdk/nio/zipfs/NewFileSystemTests.java line 224:
> 
>> 222:         // Underlying file is read-only.
>> 223:         Path readOnlyZip = Utils.createJarFile("read_only.zip", Map.of("file.txt", "Hello World"));
>> 224:         readOnlyZip.toFile().setReadOnly();
> 
> `java.io.File.setReadOnly()` specifies:
> 
>> On some platforms it may be possible to start the
>> Java virtual machine with special privileges that allow it to modify
>> files that are marked read-only. Whether or not a read-only file or
>> directory may be deleted depends upon the underlying system.
> 
> So I think we should run the subsequent asserts in this test after first checking if the file was set to read-only. If it isn't then we should skip the test. Something like:
> 
> 
> final boolean marked  = readOnlyZip.toFile().setReadOnly();
> Assumptions.assumeTrue(marked, "skipping test since " + readOnlyZip + " couldn't be marked read-only");
> assertThrows(IOException.class,
>                 () -> FileSystems.newFileSystem(readOnlyZip, Map.of("accessMode", "readWrite")));

Done. Thanks for introducing me to the Assumptions class :)

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25178#discussion_r2095780258


More information about the core-libs-dev mailing list