RFR: 8304013: Add a fast, non-manual alternative to test/jdk/java/util/zip/ZipFile/TestTooManyEntries
Eirik Bjorsnos
duke at openjdk.org
Fri Mar 24 08:12:30 UTC 2023
The TestTooManyEntries test was originally added to validate that ZIP64 files with CEN sizes exceeding what ZipFile supports are rejected with a ZipException. The test does this by creating a large ZIP file (several gigabytes) with many enties. Because this is resource intensive, the test is currently tagged as manual. (See #6927)
It would be useful to have a test which asserts the CEN size enforcement, but without the CPU, disk, memory and run time requirements of TestTooManyEntries. Such a fast test can run non-manual, without the @requires and manual tags as found in TestTooManyEntries.
This PR adds the EndOfCenValidation test which creates sparse test ZIPs where the CEN is "inflated" such that is matches the size declared in the "End of central directory" records.
While thee sparse files look large, they consume very little disk space on file systems supporting sparse files:
16 -rw-r--r-- 1 2147483702 Feb 6 18:54 bad-cen-offset.zip
16 -rw-r--r-- 1 2147483703 Feb 6 18:54 cen-size-too-large.zip
8 -rw-r--r-- 1 132 Feb 6 18:54 invalid-zen-size.zip
```
For good measure, two new test methods are added to excercise the remaining ZipExceptions which ZipFile may throw during validation of the END record .
-------------
Commit messages:
- Add a third DEFLATED entry to the test ZIP. Look up CEN offset from END header instead of skipping LOC headers. Add asserts that verifies that the ZIP has the expected entries. Write some data to the entry in the sample ZIP. Remove try/catch when opening ZipFile.
- Merge branch 'master' into zip-too-many-entries
- Inlining the openZip method makes the tests more explicit
- Clean up potentially big files after test
- Sparse files must be created explicitly on NTFS
- Merge branch 'master' into zip-too-many-entries
- Replace expectedExceptions annotations with expectThrows and assertEquals
- Merge branch 'master' into zip-too-many-entries
- Fix spelling in comment
- Inflate the CEN size using sparse files such that it matches the size declared in the End of central directory record. Add a new test which verifies the rejection of too-large CEN offset. Revert the change to END validation in ZipFile which is no longer needed.
- ... and 13 more: https://git.openjdk.org/jdk/compare/63d4afbe...e348201f
Changes: https://git.openjdk.org/jdk/pull/12231/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=12231&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8304013
Stats: 231 lines in 1 file changed: 231 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/12231.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/12231/head:pull/12231
PR: https://git.openjdk.org/jdk/pull/12231
More information about the core-libs-dev
mailing list