From 68d602822f7a110f76ae8ff1c9e75a5d5732a996 Mon Sep 17 00:00:00 2001 From: livk Date: Thu, 30 Nov 2023 17:09:01 +0800 Subject: [PATCH] refactor: Remove obsolete SpringFactoriesLoader#loadFactoryNames --- .../context/refresh/ConfigDataContextRefresher.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ConfigDataContextRefresher.java b/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ConfigDataContextRefresher.java index ac134e485..c98e4835d 100644 --- a/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ConfigDataContextRefresher.java +++ b/spring-cloud-context/src/main/java/org/springframework/cloud/context/refresh/ConfigDataContextRefresher.java @@ -28,6 +28,7 @@ import org.springframework.boot.DefaultBootstrapContext; import org.springframework.boot.SpringApplication; import org.springframework.boot.env.EnvironmentPostProcessor; +import org.springframework.boot.env.EnvironmentPostProcessorsFactory; import org.springframework.boot.logging.DeferredLogFactory; import org.springframework.cloud.autoconfigure.RefreshAutoConfiguration; import org.springframework.cloud.context.config.ContextRefreshedWithApplicationEvent; @@ -76,12 +77,8 @@ protected void updateEnvironment() { // decrypt happen after refresh. The hard coded call to // ConfigDataEnvironmentPostProcessor.applyTo() is now automated as well. DeferredLogFactory logFactory = new PassthruDeferredLogFactory(); - SpringFactoriesLoader.ArgumentResolver argumentResolver = SpringFactoriesLoader.ArgumentResolver.of(DeferredLogFactory.class, logFactory); - argumentResolver = argumentResolver.and(ConfigurableBootstrapContext.class, bootstrapContext); - argumentResolver = argumentResolver.and(BootstrapContext.class, bootstrapContext); - argumentResolver = argumentResolver.and(BootstrapRegistry.class, bootstrapContext); - SpringFactoriesLoader loader = SpringFactoriesLoader.forDefaultResourceLocation(getClass().getClassLoader()); - List postProcessors = loader.load(EnvironmentPostProcessor.class, argumentResolver); + EnvironmentPostProcessorsFactory environmentPostProcessorsFactory = EnvironmentPostProcessorsFactory.fromSpringFactories(getClass().getClassLoader()); + List postProcessors = environmentPostProcessorsFactory.getEnvironmentPostProcessors(logFactory, bootstrapContext); for (EnvironmentPostProcessor postProcessor : postProcessors) { postProcessor.postProcessEnvironment(environment, application); }