JDK-8196854 : TestFlushableGZIPOutputStream failing with IndexOutOfBoundsException
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 8u171,8u172
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-02-06
  • Updated: 2021-07-26
  • Resolved: 2018-02-09
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 7 JDK 8 Other
7u191Fixed 8u181Fixed openjdk7uFixed
Related Reports
Relates :  
Description
8u JPRT test runs are frequently failing with the following error:

java.lang.IndexOutOfBoundsException
	at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:151)
	at InflateIn_DeflateOut.TestFlushableGZIPOutputStream(InflateIn_DeflateOut.java:179)
	at InflateIn_DeflateOut.realMain(InflateIn_DeflateOut.java:311)
	at InflateIn_DeflateOut.main(InflateIn_DeflateOut.java:325)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.sun.javatest.regtest.agent.MainActionHelper$SameVMRunnable.run(MainActionHelper.java:226)
	at java.lang.Thread.run(Thread.java:748)
java.lang.AssertionError: Some tests failed
	at InflateIn_DeflateOut.main(InflateIn_DeflateOut.java:327)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.sun.javatest.regtest.agent.MainActionHelper$SameVMRunnable.run(MainActionHelper.java:226)
	at java.lang.Thread.run(Thread.java:748)

JavaTest Message: Test threw exception: java.lang.AssertionError
JavaTest Message: shutting down test

InflateIn_DeflateOut is not new but TestFlushableGZIPOutputStream was added pretty recently. I suspect an issue with the testcase itself. So far I have only seen it on ia32 and amd64 Linux. Not sure if this reproduces on JDK 10 or later versions.
Comments
The JDK 10 and later versions of this test use the new transferTo method to correctly read/write the bytes. Non applicable for JDK 10 and later.
07-02-2018

Bad test code - the read on line 178 was writing data to an unnecessary byte array and could read more than that the corresponding write array capacity. There's no need for the 'buf' array in this test section at all. 176 byte[] b = new byte[4 * 1024]; 177 try { 178 while ((numRead = gzis.read(buf)) >= 0) { 179 baos.write(b, 0, numRead); 180 } I think the following change should work : diff --git a/test/java/util/zip/InflateIn_DeflateOut.java b/test/java/util/zip/InflateIn_DeflateOut.java --- a/test/java/util/zip/InflateIn_DeflateOut.java +++ b/test/java/util/zip/InflateIn_DeflateOut.java @@ -153,7 +153,6 @@ OutputStream output = new FlushableGZIPOutputStream(byteOutStream); byte[] data = new byte[random.nextInt(1024 * 1024)]; - byte[] buf = new byte[data.length]; random.nextBytes(data); output.write(data); @@ -175,7 +174,7 @@ int numRead; byte[] b = new byte[4 * 1024]; try { - while ((numRead = gzis.read(buf)) >= 0) { + while ((numRead = gzis.read(b)) >= 0) { baos.write(b, 0, numRead); } } finally {
06-02-2018