From 789329fa3b43e917bc074537158bf2025d879263 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 20 Jun 2022 17:39:01 +0200 Subject: [PATCH] Revise signature of SpringFactoriesLoader.forResourceLocation(...) When an overloaded method accepts additional "optional" arguments, we typically declare the optional arguments after the required arguments. For example, see the constructors for ClassPathResource. This commit therefore revises the signature of the overloaded forResourceLocation() method so that the optional ClassLoader argument follows the required `String resourceLocation` argument. --- .../beans/factory/aot/AotFactoriesLoader.java | 4 ++-- .../core/io/support/SpringFactoriesLoader.java | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/aot/AotFactoriesLoader.java b/spring-beans/src/main/java/org/springframework/beans/factory/aot/AotFactoriesLoader.java index a3f1f2051f5..a3d39aa4db8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/aot/AotFactoriesLoader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/aot/AotFactoriesLoader.java @@ -62,8 +62,8 @@ public class AotFactoriesLoader { ClassLoader classLoader = (beanFactory instanceof ConfigurableBeanFactory configurableBeanFactory) ? configurableBeanFactory.getBeanClassLoader() : null; this.beanFactory = beanFactory; - this.factoriesLoader = SpringFactoriesLoader.forResourceLocation(classLoader, - FACTORIES_RESOURCE_LOCATION); + this.factoriesLoader = SpringFactoriesLoader.forResourceLocation(FACTORIES_RESOURCE_LOCATION, + classLoader); } /** diff --git a/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java b/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java index 1f1737d6657..aea829b923c 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/SpringFactoriesLoader.java @@ -296,7 +296,7 @@ public class SpringFactoriesLoader { * @see #forDefaultResourceLocation() */ public static SpringFactoriesLoader forDefaultResourceLocation(@Nullable ClassLoader classLoader) { - return forResourceLocation(classLoader, FACTORIES_RESOURCE_LOCATION); + return forResourceLocation(FACTORIES_RESOURCE_LOCATION, classLoader); } /** @@ -306,24 +306,24 @@ public class SpringFactoriesLoader { * @param resourceLocation the resource location to look for factories * @return a {@link SpringFactoriesLoader} instance * @since 6.0 - * @see #forResourceLocation(ClassLoader, String) + * @see #forResourceLocation(String, ClassLoader) */ public static SpringFactoriesLoader forResourceLocation(String resourceLocation) { - return forResourceLocation(null, resourceLocation); + return forResourceLocation(resourceLocation, null); } /** * Create a {@link SpringFactoriesLoader} instance that will load and * instantiate the factory implementations from the given location, using * the given class loader. + * @param resourceLocation the resource location to look for factories * @param classLoader the ClassLoader to use for loading resources; can be * {@code null} to use the default - * @param resourceLocation the resource location to look for factories * @return a {@link SpringFactoriesLoader} instance * @since 6.0 * @see #forResourceLocation(String) */ - public static SpringFactoriesLoader forResourceLocation(@Nullable ClassLoader classLoader, String resourceLocation) { + public static SpringFactoriesLoader forResourceLocation(String resourceLocation, @Nullable ClassLoader classLoader) { Assert.hasText(resourceLocation, "'resourceLocation' must not be empty"); ClassLoader resourceClassLoader = (classLoader != null ? classLoader : SpringFactoriesLoader.class.getClassLoader());