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 @@ -141,17 +141,18 @@ private Stream<EvaluationResult> evaluate(JavaClasses javaClasses) {
141141
142142 private void withCompileClasspath (Callable <?> callable ) throws Exception {
143143 ClassLoader previous = Thread .currentThread ().getContextClassLoader ();
144- try {
145- List <URL > urls = new ArrayList <>();
146- for (File file : getCompileClasspath ().getFiles ()) {
147- urls .add (file .toURI ().toURL ());
148- }
149- ClassLoader classLoader = new URLClassLoader (urls .toArray (new URL [0 ]), getClass ().getClassLoader ());
150- Thread .currentThread ().setContextClassLoader (classLoader );
151- callable .call ();
144+ List <URL > urls = new ArrayList <>();
145+ for (File file : getCompileClasspath ().getFiles ()) {
146+ urls .add (file .toURI ().toURL ());
152147 }
153- finally {
154- Thread .currentThread ().setContextClassLoader (previous );
148+ try (URLClassLoader classLoader = new URLClassLoader (urls .toArray (new URL [0 ]), getClass ().getClassLoader ())) {
149+ Thread .currentThread ().setContextClassLoader (classLoader );
150+ try {
151+ callable .call ();
152+ }
153+ finally {
154+ Thread .currentThread ().setContextClassLoader (previous );
155+ }
155156 }
156157 }
157158
You can’t perform that action at this time.
0 commit comments