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

Reviewed-by: aturbanov, redestad
This commit is contained in:
Jaikiran Pai 2024-05-23 01:03:19 +00:00
parent 3d4185a9ce
commit 98f6a80852

View File

@ -108,7 +108,10 @@ public class InflaterInputStreams {
@Benchmark
public void inflaterInputStreamRead() throws IOException {
deflated.reset();
InflaterInputStream iis = new InflaterInputStream(deflated);
while (iis.read(inflated, 0, inflated.length) != -1);
// We close the InflaterInputStream to release underlying native resources of the Inflater.
// The "deflated" ByteArrayInputStream remains unaffected.
try (InflaterInputStream iis = new InflaterInputStream(deflated)) {
while (iis.read(inflated, 0, inflated.length) != -1);
}
}
}