Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8338729

Retire the test jdk/java/util/zip/TestZipError.java

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • None
    • core-libs

      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.
       

            eirbjo Eirik Bjørsnøs
            eirbjo Eirik Bjørsnøs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: