RFR: 8343307: Throw ZipException instead of IAE in ZipFile.Source::initCEN

Lance Andersen lancea at openjdk.org
Wed Oct 30 18:24:06 UTC 2024


On Wed, 30 Oct 2024 16:58:40 GMT, Eirik Bjørsnøs <eirbjo at openjdk.org> wrote:

> Please review this PR which makes `ZipFile.Source::initCEN` throw `java.util.zip.ZipException` instead of `java.lang.IllegalArgumentException` when calling `ZipCoder::checkedHash` during `META-INF/versions/` parsing.
> 
> This is a follow-up to #21489 where the IAE was introduced on the premise that the earlier call to `ZipCoder::checkedHash` in `checkAndAddEntry` would already have thrown `ZipException`, so this was more of a "will never happen" assertion.
> 
> However, it's better to just be consistent and throw `ZipException`.
> 
> Testing: Added `noreg-cleanup` to the JBS. Unclear how this exception could be tested since it's shadowed by the earlier invocation of `checkedHash`. ZIP tests run green locally, GHA pending.

Thanks for the quick patch.   The fix looks good, especially given we do not indicate an IAE will be thrown in this case(regardless of how unlikely), only if the mode is invalid in the relevant constructors.

Please wait for Jai to review before integrating.

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

Marked as reviewed by lancea (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/21791#pullrequestreview-2405888169


More information about the core-libs-dev mailing list