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

Alan Bateman alanb at openjdk.org
Tue May 13 16:39:51 UTC 2025


On Tue, 13 May 2025 16:26:31 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> David Beaumont has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Fix comment based on current behaviour.
>
> src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java line 208:
> 
>> 206:         boolean shouldCreate = isTrue(env, "create");
>> 207:         if (shouldCreate && forceReadOnly) {
>> 208:             throw new IllegalArgumentException(
> 
> Although `IllegalArgumentException` seems reasonable here, the current contract of this constructor is to throw `IOException` and that then gets propagated through the public `FileSystemProvider.newFileSystem(...)` API which is specified to throw `IOException`.
> 
> So we will either have to throw `IOException` here (preferable) or we have to catch `IllegalArgumentException` at the call sites of this constructor and then rethrow it as a `IOException`, to prevent the unspecified `IllegalArgumentException` propagating out of the `FileSystemProvider.newFileSystem(...)` API.

I checked the overloads of newFileSystem that were added in JDK 13 and somehow the `@throws IllegalArgumentException` was missed. It's declared by the methods that take a URI + env but not methods that take a Path + env. We should fix that, then the IAE from the zip provider won't be a surprise.

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

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


More information about the core-libs-dev mailing list