Skip to content

Commit

Permalink
Lazy load ConfigUtil
Browse files Browse the repository at this point in the history
prevent ConfigUtil init when ApolloApplicationContextInitializer initialized,
That is too early.

This issue caused by commit 6d50ca8
  • Loading branch information
lonre authored and nobodyiam committed Aug 4, 2021
1 parent 02c43dd commit bfdfd98
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Apollo 1.9.0
* [translation of "portal-how-to-enable-webhook-notification.md"](https://github.com/ctripcorp/apollo/pull/3847)
* [feature: add history detail for not key-value type of namespace](https://github.com/ctripcorp/apollo/pull/3856)
* [fix show-text-modal number display](https://github.com/ctripcorp/apollo/pull/3851)
* [Lazy load ConfigUtil](https://github.com/ctripcorp/apollo/pull/3864)

------------------
All issues and pull requests are [here](https://github.com/ctripcorp/apollo/milestone/6?closed=1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ public class ApolloApplicationContextInitializer implements
private final ConfigPropertySourceFactory configPropertySourceFactory = SpringInjector
.getInstance(ConfigPropertySourceFactory.class);

private final ConfigUtil configUtil = ApolloInjector.getInstance(ConfigUtil.class);

private int order = DEFAULT_ORDER;

@Override
Expand Down Expand Up @@ -130,6 +128,7 @@ protected void initialize(ConfigurableEnvironment environment) {
List<String> namespaceList = NAMESPACE_SPLITTER.splitToList(namespaces);

CompositePropertySource composite;
final ConfigUtil configUtil = ApolloInjector.getInstance(ConfigUtil.class);
if (configUtil.isPropertyNamesCacheEnabled()) {
composite = new CachedCompositePropertySource(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class PropertySourcesProcessor implements BeanFactoryPostProcessor, Envir

private final ConfigPropertySourceFactory configPropertySourceFactory = SpringInjector
.getInstance(ConfigPropertySourceFactory.class);
private final ConfigUtil configUtil = ApolloInjector.getInstance(ConfigUtil.class);
private ConfigUtil configUtil;
private ConfigurableEnvironment environment;

public static boolean addNamespaces(Collection<String> namespaces, int order) {
Expand All @@ -71,6 +71,7 @@ public static boolean addNamespaces(Collection<String> namespaces, int order) {

@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
this.configUtil = ApolloInjector.getInstance(ConfigUtil.class);
initializePropertySources();
initializeAutoUpdatePropertiesFeature(beanFactory);
}
Expand Down

0 comments on commit bfdfd98

Please sign in to comment.