Skip to content

Commit 15bb54a

Browse files
committed
Merge pull request #50949 from SebTardif
Closes gh-50949 * fix/findmainclass-close-jarfile: Close JarFile when finding main class from archive
2 parents f01e775 + c3153dc commit 15bb54a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • build-plugin/spring-boot-antlib/src/main/java/org/springframework/boot/ant

build-plugin/spring-boot-antlib/src/main/java/org/springframework/boot/ant/FindMainClass.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ public void execute() throws BuildException {
7171
if (this.classesRoot.isDirectory()) {
7272
return MainClassFinder.findSingleMainClass(this.classesRoot, SPRING_BOOT_APPLICATION_CLASS_NAME);
7373
}
74-
return MainClassFinder.findSingleMainClass(new JarFile(this.classesRoot), "/",
75-
SPRING_BOOT_APPLICATION_CLASS_NAME);
74+
try (JarFile jarFile = new JarFile(this.classesRoot)) {
75+
return MainClassFinder.findSingleMainClass(jarFile, "/", SPRING_BOOT_APPLICATION_CLASS_NAME);
76+
}
7677
}
7778
catch (IOException ex) {
7879
throw new BuildException(ex);

0 commit comments

Comments
 (0)