mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Close JarFile when finding main class from archive
MainClassFinder.findSingleMainClass(JarFile, ...) does not close the JarFile; the caller owns the resource. FindMainClass passed a newly opened JarFile without closing it, unlike sibling call sites that use try-with-resources. See gh-50949 Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
This commit is contained in:
committed by
Stéphane Nicoll
parent
f01e775082
commit
c3153dc39f
+3
-2
@@ -71,8 +71,9 @@ public class FindMainClass extends Task {
|
||||
if (this.classesRoot.isDirectory()) {
|
||||
return MainClassFinder.findSingleMainClass(this.classesRoot, SPRING_BOOT_APPLICATION_CLASS_NAME);
|
||||
}
|
||||
return MainClassFinder.findSingleMainClass(new JarFile(this.classesRoot), "/",
|
||||
SPRING_BOOT_APPLICATION_CLASS_NAME);
|
||||
try (JarFile jarFile = new JarFile(this.classesRoot)) {
|
||||
return MainClassFinder.findSingleMainClass(jarFile, "/", SPRING_BOOT_APPLICATION_CLASS_NAME);
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new BuildException(ex);
|
||||
|
||||
Reference in New Issue
Block a user