Skip to content

Commit 21a5319

Browse files
committed
Revert "Use Framework's default class loader as default in ImportCandidates"
This reverts commit 56c9551. See gh-44401
1 parent a0ff9f6 commit 21a5319

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation/ImportCandidates.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2025 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,7 +29,6 @@
2929

3030
import org.springframework.core.io.UrlResource;
3131
import org.springframework.util.Assert;
32-
import org.springframework.util.ClassUtils;
3332

3433
/**
3534
* Contains {@code @Configuration} import candidates, usually auto-configurations.
@@ -75,8 +74,7 @@ public List<String> getCandidates() {
7574
* Every line contains the full qualified name of the candidate class. Comments are
7675
* supported using the # character.
7776
* @param annotation annotation to load
78-
* @param classLoader class loader to use for loading, or {@code null} to use the
79-
* {@link ClassUtils#getDefaultClassLoader() default class loader}
77+
* @param classLoader class loader to use for loading
8078
* @return list of names of annotated classes
8179
*/
8280
public static ImportCandidates load(Class<?> annotation, ClassLoader classLoader) {
@@ -94,7 +92,7 @@ public static ImportCandidates load(Class<?> annotation, ClassLoader classLoader
9492

9593
private static ClassLoader decideClassloader(ClassLoader classLoader) {
9694
if (classLoader == null) {
97-
return ClassUtils.getDefaultClassLoader();
95+
return ImportCandidates.class.getClassLoader();
9896
}
9997
return classLoader;
10098
}

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/annotation/ImportCandidatesTests.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class ImportCandidatesTests {
4747
4848
""")
4949
void loadReadsFromClasspathFile() {
50-
ImportCandidates candidates = ImportCandidates.load(TestAnnotation.class, null);
50+
ImportCandidates candidates = ImportCandidates.load(TestAnnotation.class,
51+
Thread.currentThread().getContextClassLoader());
5152
assertThat(candidates).containsExactly("class1", "class2", "class3");
5253
}
5354

0 commit comments

Comments
 (0)