RFR: 8349914: ZipFile::entries and ZipFile::getInputStream not consistent with each other when there are duplicate entries

Jaikiran Pai jpai at openjdk.org
Fri Jun 6 02:10:12 UTC 2025


On Wed, 4 Jun 2025 09:53:13 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

> Can I please get a review of this change which proposes to address the issue noted in https://bugs.openjdk.org/browse/JDK-8349914?
> 
> The ZIP specification allows for more than one entry to have the same file name (and may have different file data). In such situation, as noted in the linked issue, the `ZipFile.getInputStream(ZipEntry)` may end up picking up an "incorrect" entry content (and metadata) for the passed entry.
> 
> The commit in this PR addresses that issue by holding on to the LOC offset of the entry in the `ZipEntry` class. This way, whenever that `ZipEntry` instance is used, it knows which exact entry it represents.
> 
> A new jtreg test has been introduced to reproduce the issue and verify the fix. The new test and existing tests in tier1, tier2 and tier3 pass with this change.

Thank you Lance for the review.

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

PR Comment: https://git.openjdk.org/jdk/pull/25635#issuecomment-2947807108


More information about the core-libs-dev mailing list