RFR: 8332490: JMH org.openjdk.bench.java.util.zip.InflaterInputStreams.inflaterInputStreamRead OOM

Claes Redestad redestad at openjdk.org
Wed May 22 07:31:09 UTC 2024


On Wed, 22 May 2024 07:20:04 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Can I please get a review of this test-only change for addressing https://bugs.openjdk.org/browse/JDK-8332490?
>> 
>> The jmh test opens a `InflaterInputStream`, reads the stream contents, but then doesn't close the stream. This can lead to resource leak which can then cause OOM as noted in that JBS issue.
>> 
>> The commit in this PR closes the `InflaterInputStream` when the reads complete.
>> 
>> 
>> make test TEST=micro:org.openjdk.bench.java.util.zip.InflaterInputStreams
>> 
>> and
>> 
>> 
>> ./build/macosx-aarch64/images/jdk/bin/java -jar ./build/macosx-aarch64/images/test/micro/benchmarks.jar org.openjdk.bench.java.util.zip.InflaterInputStreams.inflaterInputStreamRead -t max -f 1 -wi 2 -foe true
>> 
>> pass after this change.
>
> test/micro/org/openjdk/bench/java/util/zip/InflaterInputStreams.java line 113:
> 
>> 111:         try (InflaterInputStream iis = new InflaterInputStream(deflated)) {
>> 112:             while (iis.read(inflated, 0, inflated.length) != -1);
>> 113:         }
> 
> Presumably this only works because closing the underlying stream (a BAOS in this case) is a no-op.

Yes, the underlying BAIS can be repeatedly closed without affecting the benchmark.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/19340#discussion_r1609436837


More information about the core-libs-dev mailing list