From 5a58e3d974123eabde7aa8ee24b0e47eb3429d76 Mon Sep 17 00:00:00 2001 From: liaozan <378024053@qq.com> Date: Sat, 1 Jul 2023 01:22:48 +0800 Subject: [PATCH] Add implements note for ConfigurablePropertiesLoader#load --- .../apollo/ConfigurablePropertiesLoader.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/ConfigurablePropertiesLoader.java b/starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/ConfigurablePropertiesLoader.java index 7f2ae01..8a3eaab 100644 --- a/starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/ConfigurablePropertiesLoader.java +++ b/starters/apollo-spring-boot-starter/src/main/java/com/schbrain/framework/autoconfigure/apollo/ConfigurablePropertiesLoader.java @@ -39,9 +39,12 @@ class ConfigurablePropertiesLoader { this.log = deferredLogFactory.getLog(ConfigurablePropertiesLoader.class); } + /** + * Do not use asynchronous or thread pool to speed up configuration loading, as this may break the priority of configuration properties + */ void load(ConfigurableEnvironment environment, SpringApplication application) { - List configurableProperties = loadFactories(ConfigurableProperties.class, getClass().getClassLoader()); - if (CollectionUtils.isEmpty(configurableProperties)) { + List propertiesList = loadFactories(ConfigurableProperties.class, getClass().getClassLoader()); + if (CollectionUtils.isEmpty(propertiesList)) { log.warn("There is no configuration properties found"); return; } @@ -49,15 +52,15 @@ class ConfigurablePropertiesLoader { ApplicationEventMulticaster eventMulticaster = createEventMulticaster(application.getListeners()); boolean remoteFirst = ApolloProperties.get(environment).isRemoteFirst(); - configurableProperties.parallelStream().forEach(properties -> { + for (ConfigurableProperties properties : propertiesList) { OrderedMapPropertySource propertySource = loadFromRemote(environment, remoteFirst, properties.getNamespace()); if (propertySource == null) { - return; + continue; } // multicast event ConfigLoadedEvent event = createEvent(environment, application, propertySource, properties); eventMulticaster.multicastEvent(event, ResolvableType.forClass(event.getClass())); - }); + } } private OrderedMapPropertySource loadFromRemote(ConfigurableEnvironment environment, boolean remoteFirst, String namespace) { -- GitLab