RFR(S): 8240226: DeflateIn_InflateOut.java test incorrectly assumes size of compressed file

Volker Simonis volker.simonis at gmail.com
Fri Feb 28 16:05:47 UTC 2020

On Fri, Feb 28, 2020 at 4:40 PM Martin Buchholz <martinrb at google.com> wrote:

Thanks, for your review Martin.

> We're all resisting the urge to modernize this test.

I have some more zip-related fixes in the queue :)

> On Fri, Feb 28, 2020 at 5:17 AM Volker Simonis <volker.simonis at gmail.com> wrote:
>> Hi,
>> can I please get a review for this trivial test fix:
>> http://cr.openjdk.java.net/~simonis/webrevs/2020/8240226/
>> https://bugs.openjdk.java.net/browse/JDK-8240226
>> 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 of, 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
>> (although there's no guarantee for this), 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 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 test may (and actually does) randomly fail at any of the subtests
>> executed in SkipBytes() which reuse "numReadable", the size of the
>> first deflated stream generated in that method.
>> 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.
>> Thank you and best regards,
>> Volker

More information about the core-libs-dev mailing list