Skip to content

Commit 98f6a80

Browse files
committed
8332490: JMH org.openjdk.bench.java.util.zip.InflaterInputStreams.inflaterInputStreamRead OOM
Reviewed-by: aturbanov, redestad
1 parent 3d4185a commit 98f6a80

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/micro/org/openjdk/bench/java/util/zip/InflaterInputStreams.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ public void beforeIteration() throws IOException {
108108
@Benchmark
109109
public void inflaterInputStreamRead() throws IOException {
110110
deflated.reset();
111-
InflaterInputStream iis = new InflaterInputStream(deflated);
112-
while (iis.read(inflated, 0, inflated.length) != -1);
111+
// We close the InflaterInputStream to release underlying native resources of the Inflater.
112+
// The "deflated" ByteArrayInputStream remains unaffected.
113+
try (InflaterInputStream iis = new InflaterInputStream(deflated)) {
114+
while (iis.read(inflated, 0, inflated.length) != -1);
115+
}
113116
}
114117
}

0 commit comments

Comments
 (0)