Skip to content

Commit 8bcab02

Browse files
linw-baisnicoll
authored andcommitted
Use beanClassLoader when checking excluded auto-configuration classes
When validating exclusions, prefer the selector's beanClassLoader for ClassUtils.isPresent checks and fall back to the selector class loader if the beanClassLoader is not set. This makes presence checks consistent with the classloader context used for loading auto-configuration candidates. See gh-48129 Signed-off-by: linw-bai <107357009+linw-bai@users.noreply.github.com>
1 parent 2f1f964 commit 8bcab02

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@ protected List<String> getCandidateConfigurations(AnnotationMetadata metadata, A
205205

206206
private void checkExcludedClasses(List<String> configurations, Set<String> exclusions) {
207207
List<String> invalidExcludes = new ArrayList<>(exclusions.size());
208+
ClassLoader classLoader = (this.beanClassLoader != null) ? this.beanClassLoader : getClass().getClassLoader();
208209
for (String exclusion : exclusions) {
209-
if (ClassUtils.isPresent(exclusion, getClass().getClassLoader()) && !configurations.contains(exclusion)) {
210+
if (ClassUtils.isPresent(exclusion, classLoader) && !configurations.contains(exclusion)) {
210211
invalidExcludes.add(exclusion);
211212
}
212213
}

0 commit comments

Comments
 (0)