JDK-8338729 : Retire the test jdk/java/util/zip/TestZipError.java
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-08-21
  • Updated: 2024-09-02
  • Resolved: 2024-08-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 24
24 b13Fixed
Related Reports
Relates :  
Description
The ZipFile test TestZipError.java has fallen out of sync with its original and stated purpose as described in its @summary tag, code comments and also its name.

The test was initially added in JDK-4615343 (Java 6) to exercise code paths which caused ZipFile entry enumeration to throw a ZipError (a subclass of InternalError).

With the rewrite of the ZipFile from native to Java in JDK-8145260 (JDK 9), the code tested would no longer throw ZipError and the ZipError class fell completely out of use in OpenJDK.

JDK-8145260 also updated the TestZipError.java to catch ZipException instead of ZipError for the expected/passing case. Interestingly, a line was added which cases the test to not only enumerate the entries of the updated ZipFile, but to actually consume the input stream of the entries.

This added line causes ZipFileInputStream.initDataOffset to throw a ZipException when the CEN local header offset does not contain the expected LOC header, resulting in a ZipException with the message "ZipFile invalid LOC header (bad signature)". This subtle updated caused the test to (accidentally?) test something which is actually quite different than its original purpose. 

The "invalid LOC header" scenario is currently better tested by the ZipSourceCache test, which also runs on non-windows platforms.

Instead of trying to fix the name, summary, code comments of the currently confusing TestZipError.java test, I suggest that we simply retire it in favor of ZipSourceCache, which is a JUnit test and also runs on non-Windows platforms. 
 
Comments
Changeset: b6700095 Branch: master Author: Eirik Bjørsnøs <eirbjo@openjdk.org> Date: 2024-08-28 15:23:50 +0000 URL: https://git.openjdk.org/jdk/commit/b6700095c018a67a55b746cd4eee763c68f538e0
28-08-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/20660 Date: 2024-08-21 09:59:38 +0000
23-08-2024