RFR: 6714834: JarFile.getManifest() leaves an open InputStream as an undocumented side effect [v2]

Jaikiran Pai jpai at openjdk.java.net
Tue Sep 15 15:43:23 UTC 2020


On Tue, 15 Sep 2020 15:29:44 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Jaikiran Pai has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Remove "final"
>
> src/java.base/share/classes/java/util/jar/JarFile.java line 428:
> 
>> 426:                     try (final InputStream is = super.getInputStream(manEntry)) {
>> 427:                         man = new Manifest(is, getName());
>> 428:                     }
> 
> There is a cleaner so shouldn't have a leak, even if the JarFile is not explicitly closed.
> The noisy "final" can be dropped, otherwise looks good.

Thank you for the review Alan. I've updated this PR to remove the `final`. And yes as you note, this doesn't really
leak. This change closes the InputStream earlier, as soon as it is done, instead of waiting for the `Cleaner` to kick
in.

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

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


More information about the core-libs-dev mailing list