Skip to content

Commit 56c9551

Browse files
committed
Use Framework's default class loader as default in ImportCandidates
Closes gh-44401
1 parent 3acea58 commit 56c9551

File tree

1 file changed

+5
-3
lines changed
  • spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/annotation

1 file changed

+5
-3
lines changed

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2025 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,6 +29,7 @@
2929

3030
import org.springframework.core.io.UrlResource;
3131
import org.springframework.util.Assert;
32+
import org.springframework.util.ClassUtils;
3233

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

9395
private static ClassLoader decideClassloader(ClassLoader classLoader) {
9496
if (classLoader == null) {
95-
return ImportCandidates.class.getClassLoader();
97+
return ClassUtils.getDefaultClassLoader();
9698
}
9799
return classLoader;
98100
}

0 commit comments

Comments
 (0)