Can I please get a review of this change which addresses the issue noted in 
https://bugs.openjdk.org/browse/JDK-8358456?

In Java 24, through https://bugs.openjdk.org/browse/JDK-8341597 we did a change 
which started using the "compressed size" field value for computing a input 
buffer size for the `InflaterInputStream`. The change was reasonable. One part 
of the change removed a check for  ` <= 0` which would have taken into account 
invalid/unexpected "compressed size" values:
>From https://github.com/openjdk/jdk/pull/21379
> There is a check for size <= 0. This condition is unreachable in the current 
> code and in the PR as well, since the compressed size will always be >= 2. I 
> propose we remove this check.

Without that check, the computed input buffer size can end up being `<= 0` 
which is an invalid value for a buffer size and thus results in an 
`IllegalArgumentException` from the `InflaterInputStream` constructor.

My initial thought was to catch the the `IllegalArgumentException` and rethrow 
a `ZipException`, but thinking about it, this clearly is more an issue with the 
value that we computed as an input buffer size. So I believe the right thing 
here is to reintroduce the check that was previously in place and in such cases 
just default to reasonable sized buffer. That's what the commit in this PR 
does. Additionally, I renamed that variable to `inputBufSize` to be clear what 
this `size` represents.

A new jtreg test has been introduced which reproduces the issue and verifies 
the fix. tier testing is currently in progress.

P.S: As a separate task we might want to do a similar change as what was done 
in JDK-8341597, to the `ZipFileSystem` code. It currently uses the uncompressed 
size of the entry to decide the input buffer size.

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

Commit messages:
 - 8358456: ZipFile.getInputStream(ZipEntry) throws unspecified 
IllegalArgumentException

Changes: https://git.openjdk.org/jdk/pull/25606/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25606&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8358456
  Stats: 132 lines in 2 files changed: 124 ins; 0 del; 8 mod
  Patch: https://git.openjdk.org/jdk/pull/25606.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/25606/head:pull/25606

PR: https://git.openjdk.org/jdk/pull/25606

Reply via email to