Use try with resources instead of try-finally

See gh-39259
This commit is contained in:
Tobias Lippert
2024-01-21 18:54:01 +01:00
committed by Phillip Webb
parent cb26c31dd6
commit 316b415e95

View File

@@ -413,7 +413,7 @@ class NestedJarFileTests {
}
private List<String> collectComments(JarFile jarFile) throws IOException {
try {
try (jarFile) {
List<String> comments = new ArrayList<>();
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
@@ -424,9 +424,6 @@ class NestedJarFileTests {
}
return comments;
}
finally {
jarFile.close();
}
}
}