On Fri, 9 Jul 2021 08:21:21 GMT, Lin Zang <lz...@openjdk.org> wrote:

>> 8269909: getStack method in hprof.parser.Reader should use try-with-resource
>
> Lin Zang has updated the pull request with a new target base due to a merge 
> or a rebase. The incremental webrev excludes the unrelated changes brought in 
> by the merge/rebase. The pull request contains two additional commits since 
> the last revision:
> 
>  - Merge branch 'master' into try
>  - 8269909: getStack method in hprof.parser.Reader should use 
> try-with-resource

Hi Lin,

I think this is only a partial conversion to try-with-resources.

David

test/lib/jdk/test/lib/hprof/parser/Reader.java line 154:

> 152:                 File out = new File(deCompressedFile);
> 153:                 // Decompress to get dump file.
> 154:                 try (GZIPInputStream gis = new GZIPInputStream(new 
> FileInputStream(heapFile));

GZipInutStream close() doesn't say anything about closing the original stream, 
so I think you need to expand this so that you first create the FIS, then the 
GZIPIS then the FOS.

test/lib/jdk/test/lib/hprof/parser/Reader.java line 167:

> 165:                 // Check dump data header and print stack trace.
> 166:                 try (PositionDataInputStream in2 = new 
> PositionDataInputStream(
> 167:                         new BufferedInputStream(new 
> FileInputStream(out)))) {

Similarly here. You first need to define and create the FIS, then the BIS, then 
the PDIS.

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

Changes requested by dholmes (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/4717

Reply via email to