8373699: JLink: ModuleReader should be closed in JlinkTask.getReleaseInfo(mref)

Reviewed-by: alanb
This commit is contained in:
Henry Jen 2026-01-26 17:19:44 +00:00
parent 67beb9cd81
commit b42861a2aa

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -248,8 +248,8 @@ public class JlinkTask {
* Read the release.txt from the module. * Read the release.txt from the module.
*/ */
private static Optional<String> getReleaseInfo(ModuleReference mref) { private static Optional<String> getReleaseInfo(ModuleReference mref) {
try { try (var moduleReader = mref.open()) {
Optional<InputStream> release = mref.open().open(JDK_RELEASE_RESOURCE); Optional<InputStream> release = moduleReader.open(JDK_RELEASE_RESOURCE);
if (release.isEmpty()) { if (release.isEmpty()) {
return Optional.empty(); return Optional.empty();