Skip to content

Commit 316b415

Browse files
tobias-lippertphilwebb
authored andcommitted
Use try with resources instead of try-finally
See gh-39259
1 parent cb26c31 commit 316b415

File tree

1 file changed

+1
-4
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar

1 file changed

+1
-4
lines changed

spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/jar/NestedJarFileTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ void getCommentAlignsWithJdkJar() throws Exception {
413413
}
414414

415415
private List<String> collectComments(JarFile jarFile) throws IOException {
416-
try {
416+
try (jarFile) {
417417
List<String> comments = new ArrayList<>();
418418
Enumeration<JarEntry> entries = jarFile.entries();
419419
while (entries.hasMoreElements()) {
@@ -424,9 +424,6 @@ private List<String> collectComments(JarFile jarFile) throws IOException {
424424
}
425425
return comments;
426426
}
427-
finally {
428-
jarFile.close();
429-
}
430427
}
431428

432429
}

0 commit comments

Comments
 (0)