apolloconfig / apolloconfig/apollo
当ApolloPropertySources为null时,会将ProperitySources添加到env中,显示[]的列表
- Lingua principale
- Java
- Stelle
- 29.8k
- Fork
- 10.2k
- Merge medio
- 4g 7h
- PR unite (30g)
- 4
Descrizione
现象:
- 在执行PropertySourcesProcessor的initializePropertySources逻辑时,当未使用EnableApolloConfig注解时,NAMESPACE_NAMES列表为null,随后在添加ApolloPropertySources时,未进行列表判空操作,导致env中propertySources列表中会有ApolloPropertySources为[]的选项。

修改方法:
1、将 ensureBootstrapPropertyPrecedence(environment)
的逻辑跟添加ApolloPropertySources到env中的逻辑分开,目的是不影响这段的执行。
2、添加ApolloPropertySources中列表的size判断操作。
`
if (composite.getPropertySources() != null && composite.getPropertySources().size() > 0) {
// add after the bootstrap property source or to the first
if (environment.getPropertySources()
.contains(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME))
environment.getPropertySources()
.addAfter(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME, composite);
} else {
environment.getPropertySources().addFirst(composite);
}
}`
* 修改后的结果

Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.