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

DeflateIn_InflateOut.java test incorrectly assumes size of compressed file

XMLWordPrintable

        The SkipBytes() subtest in DeflateIn_InflateOut.java executes several steps and for each step it deflates an array of 1024*1024 bytes. In every step, before deflation is performed, the array is refilled with random bytes. However, only after the first step, the size of the generated, deflated stream is checked and recorded. The following subtests all assume that deflating the array filled with the same number but different random bytes will produce a deflated stream of the same size.

        This assumption is wrong. Depending on the exact contents of the source array, the size of the generated, deflated result might slightly differ. For some reason, the deflated result produced by the default zlib implementation seems to always have the same size, but other zlib implementations sometimes produce differently sized, deflated results.

        The problem can easily be reproduced by placing a version of Cloudflare's zlib clone (https://github.com/cloudflare/zlib) on the LD_LIBRARY_PATH (for jdk versions configured with "--with-zlib=system", which is the default since jdk11):

        $ LD_LIBRARY_PATH=/ziptests/build/zlib-cloudflare ./images/jdk/bin/java -cp JTwork_cf/classes/java/util/zip/DeflateIn_InflateOut.d DeflateIn_InflateOut
        java.lang.Exception: Stack trace
        at java.base/java.lang.Thread.dumpStack(Thread.java:1379)
        at DeflateIn_InflateOut.fail(DeflateIn_InflateOut.java:235)
        at DeflateIn_InflateOut.check(DeflateIn_InflateOut.java:238)
        at DeflateIn_InflateOut.SkipBytes(DeflateIn_InflateOut.java:204)
        at DeflateIn_InflateOut.realMain(DeflateIn_InflateOut.java:229)
        at DeflateIn_InflateOut.main(DeflateIn_InflateOut.java:243)

        Passed = 16 failed = 1
        Exception in thread "main" java.lang.AssertionError: Some tests failed
        at DeflateIn_InflateOut.main(DeflateIn_InflateOut.java:245)


        The fix is trivial. It is unnecessary to refill the source array with random bytes before each subtest. Filling the array one time at test startup time should be sufficient.
         

              simonis Volker Simonis
              simonis Volker Simonis
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: