Skip to content

Commit 171a4c6

Browse files
SendaoYanRealCLanger
authored andcommitted
8332490: JMH org.openjdk.bench.java.util.zip.InflaterInputStreams.inflaterInputStreamRead OOM
Backport-of: 98f6a80852383dcbdad7292b7d269a8547d54d45
1 parent b7c7006 commit 171a4c6

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)