19
19
import java .io .IOException ;
20
20
import java .net .URL ;
21
21
import java .util .ArrayList ;
22
- import java .util .Arrays ;
23
22
import java .util .Collections ;
24
23
import java .util .Enumeration ;
25
24
import java .util .List ;
@@ -82,9 +81,9 @@ public abstract class SpringFactoriesLoader {
82
81
* to obtain all registered factory names.
83
82
* @param factoryClass the interface or abstract class representing the factory
84
83
* @param classLoader the ClassLoader to use for loading (can be {@code null} to use the default)
85
- * @see #loadFactoryNames
86
84
* @throws IllegalArgumentException if any factory implementation class cannot
87
85
* be loaded or if an error occurs while instantiating any factory
86
+ * @see #loadFactoryNames
88
87
*/
89
88
public static <T > List <T > loadFactories (Class <T > factoryClass , @ Nullable ClassLoader classLoader ) {
90
89
Assert .notNull (factoryClass , "'factoryClass' must not be null" );
@@ -111,8 +110,8 @@ public static <T> List<T> loadFactories(Class<T> factoryClass, @Nullable ClassLo
111
110
* @param factoryClass the interface or abstract class representing the factory
112
111
* @param classLoader the ClassLoader to use for loading resources; can be
113
112
* {@code null} to use the default
114
- * @see #loadFactories
115
113
* @throws IllegalArgumentException if an error occurs while loading factory names
114
+ * @see #loadFactories
116
115
*/
117
116
public static List <String > loadFactoryNames (Class <?> factoryClass , @ Nullable ClassLoader classLoader ) {
118
117
String factoryClassName = factoryClass .getName ();
@@ -135,9 +134,10 @@ private static Map<String, List<String>> loadSpringFactories(@Nullable ClassLoad
135
134
UrlResource resource = new UrlResource (url );
136
135
Properties properties = PropertiesLoaderUtils .loadProperties (resource );
137
136
for (Map .Entry <?, ?> entry : properties .entrySet ()) {
138
- List <String > factoryClassNames = Arrays .asList (
139
- StringUtils .commaDelimitedListToStringArray ((String ) entry .getValue ()));
140
- result .addAll ((String ) entry .getKey (), factoryClassNames );
137
+ String factoryClassName = ((String ) entry .getKey ()).trim ();
138
+ for (String factoryName : StringUtils .commaDelimitedListToStringArray ((String ) entry .getValue ())) {
139
+ result .add (factoryClassName , factoryName .trim ());
140
+ }
141
141
}
142
142
}
143
143
cache .put (classLoader , result );
0 commit comments