RFR: 8349914: ZipFile::entries and ZipFile::getInputStream not consistent with each other when there are duplicate entries
Jaikiran Pai
jpai at openjdk.org
Wed Jun 4 13:20:39 UTC 2025
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.
-------------
Commit messages:
- 8349914: ZipFile::entries and ZipFile::getInputStream not consistent with each other when there are duplicate entries
Changes: https://git.openjdk.org/jdk/pull/25635/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25635&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8349914
Stats: 237 lines in 3 files changed: 233 ins; 0 del; 4 mod
Patch: https://git.openjdk.org/jdk/pull/25635.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/25635/head:pull/25635
PR: https://git.openjdk.org/jdk/pull/25635
More information about the core-libs-dev
mailing list