Use ResourceLoader.getClassLoader() for factories

Update `SpringApplication` to load and initialize `spring.factories`
classes using the `ResourceLoader.getClassLoader()`.

Closes gh-14641
pull/14688/head
Phillip Webb 6 years ago
parent daa3d457b7
commit 6baaa3df77

@ -447,7 +447,7 @@ public class SpringApplication {
private <T> Collection<T> getSpringFactoriesInstances(Class<T> type, private <T> Collection<T> getSpringFactoriesInstances(Class<T> type,
Class<?>[] parameterTypes, Object... args) { Class<?>[] parameterTypes, Object... args) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); ClassLoader classLoader = getClassLoader();
// Use names and ensure unique to protect against duplicates // Use names and ensure unique to protect against duplicates
Set<String> names = new LinkedHashSet<>( Set<String> names = new LinkedHashSet<>(
SpringFactoriesLoader.loadFactoryNames(type, classLoader)); SpringFactoriesLoader.loadFactoryNames(type, classLoader));

Loading…
Cancel
Save