From 6baaa3df774fd75f929dd9507f798a1cc1949177 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 4 Oct 2018 13:56:56 -0700 Subject: [PATCH] Use ResourceLoader.getClassLoader() for factories Update `SpringApplication` to load and initialize `spring.factories` classes using the `ResourceLoader.getClassLoader()`. Closes gh-14641 --- .../main/java/org/springframework/boot/SpringApplication.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index 0f5c520489..d5984750e9 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -447,7 +447,7 @@ public class SpringApplication { private Collection getSpringFactoriesInstances(Class type, Class[] parameterTypes, Object... args) { - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + ClassLoader classLoader = getClassLoader(); // Use names and ensure unique to protect against duplicates Set names = new LinkedHashSet<>( SpringFactoriesLoader.loadFactoryNames(type, classLoader));