RFR: 8350880: (zipfs) Add support for read-only zip file systems [v3]
Jaikiran Pai
jpai at openjdk.org
Wed May 14 06:53:55 UTC 2025
On Tue, 13 May 2025 16:37:12 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> 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.
I'll file an issue for this today, shortly.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25178#discussion_r2088183284
More information about the core-libs-dev
mailing list