On Mon, 12 May 2025 10:16:33 GMT, David Beaumont <[email protected]> wrote:
>> Adding read-only support to ZipFileSystem.
>>
>> The new `accessMode` environment property allows for readOnly and readWrite
>> values, and ensures that the requested mode is consistent with what's
>> returned.
>>
>> This involved a little refactoring to ensure that "read only" state was set
>> initially and only unset at the end of initialization if appropriate.
>>
>> By making 2 methods return values (rather than silently set non-final fields
>> as a side effect) it's now clear in what order fields are initialized and
>> which are final (sadly there are still non-final fields, but only a split of
>> this class into two types can fix that, since determining multi-jar support
>> requires reading the file system).
>
> David Beaumont has updated the pull request incrementally with one additional
> commit since the last revision:
>
> Fix comment based on current behaviour.
test/jdk/jdk/nio/zipfs/NewFileSystemTests.java line 207:
> 205: Map.of("create", true, "accessMode",
> "badValue")));
> 206: }
> 207:
You could simplify the above tests using a DataProvider similar to
@DataProvider(name = "zipfsMap")
protected Object[][] zipfsMap() {
return new Object[][]{
{Map.of(), NoSuchFileException.class},
{Map.of("accessMode", "readOnly"), NoSuchFileException.class},
{Map.of("accessMode", "readWrite"), NoSuchFileException.class},
{Map.of("create", true, "accessMode", "readOnly"),
IllegalArgumentException.class},
{Map.of("create", true, "accessMode", "badValue"),
IllegalArgumentException.class},
};
@Test(dataProvider = "zipfsMapā)
public void testZipFSCreationException(Map<String, String> env, Class<T>
exception) throws Exception {
assertThrows(exception, () -> FileSystems.newFileSystem(noSuchZip, env));
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25178#discussion_r2089378491