Skip to content

Commit

Permalink
refactor: Remove obsolete SpringFactoriesLoader#loadFactoryNames
Browse files Browse the repository at this point in the history
  • Loading branch information
livk-cloud committed Nov 30, 2023
1 parent 75d8311 commit 68d6028
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<EnvironmentPostProcessor> postProcessors = loader.load(EnvironmentPostProcessor.class, argumentResolver);
EnvironmentPostProcessorsFactory environmentPostProcessorsFactory = EnvironmentPostProcessorsFactory.fromSpringFactories(getClass().getClassLoader());
List<EnvironmentPostProcessor> postProcessors = environmentPostProcessorsFactory.getEnvironmentPostProcessors(logFactory, bootstrapContext);
for (EnvironmentPostProcessor postProcessor : postProcessors) {
postProcessor.postProcessEnvironment(environment, application);
}
Expand Down

0 comments on commit 68d6028

Please sign in to comment.