File tree Expand file tree Collapse file tree
buildSrc/src/main/java/org/springframework/boot/build/architecture Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -132,17 +132,18 @@ private Stream<EvaluationResult> evaluate(JavaClasses javaClasses) {
132132
133133 private void withCompileClasspath (Callable <?> callable ) throws Exception {
134134 ClassLoader previous = Thread .currentThread ().getContextClassLoader ();
135- try {
136- List <URL > urls = new ArrayList <>();
137- for (File file : getCompileClasspath ().getFiles ()) {
138- urls .add (file .toURI ().toURL ());
139- }
140- ClassLoader classLoader = new URLClassLoader (urls .toArray (new URL [0 ]), getClass ().getClassLoader ());
141- Thread .currentThread ().setContextClassLoader (classLoader );
142- callable .call ();
135+ List <URL > urls = new ArrayList <>();
136+ for (File file : getCompileClasspath ().getFiles ()) {
137+ urls .add (file .toURI ().toURL ());
143138 }
144- finally {
145- Thread .currentThread ().setContextClassLoader (previous );
139+ try (URLClassLoader classLoader = new URLClassLoader (urls .toArray (new URL [0 ]), getClass ().getClassLoader ())) {
140+ Thread .currentThread ().setContextClassLoader (classLoader );
141+ try {
142+ callable .call ();
143+ }
144+ finally {
145+ Thread .currentThread ().setContextClassLoader (previous );
146+ }
146147 }
147148 }
148149
You can’t perform that action at this time.
0 commit comments