Skip to content

Commit 48463ed

Browse files
committed
Merge branch '4.0.x'
Closes gh-50637
2 parents 894c2bf + f6ab34b commit 48463ed

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

buildSrc/src/main/java/org/springframework/boot/build/architecture/ArchitectureCheck.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)