yhs0092 opened a new issue #2657:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2657
特定的microservice.yaml配置错误会触发`YAMLUtil`加载配置文件报错, 复现用例如下:
```yaml
servicecomb:
local:
registry:
enabled: {{true}}
```
`YAMLUtil` 会误以为`{{true}}`是一个配置层级,
形成key为`LinkedHashMap`而value为`null`的一个配置map, 导致报错. 异常会击穿Java-Chassis 的配置文件加载逻辑,
导致本应打印的 microservice.yaml 文件扫描列表不打了, 不利于问题排查.
测试发现 1.3.6 和 2.3.6 版本的Java-Chassis均有此问题.
建议框架侧优化一下相关逻辑, 在加载失败时打出相关配置文件位置, 便于定位问题.
另外, 希望这个优化能够同步到 1.3 版本分支, 多谢 : )
异常栈如下:
```
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'org.apache.servicecomb.core.ConfigurationSpringInitializer#0'
defined in URL
[jar:file:/D:/maven/repository_yunlong/com/huawei/wisecloud/nuwa/nuwa-cse-foundation/3.1.0.001-SNAPSHOT/nuwa-cse-foundation-3.1.0.001-SNAPSHOT.jar!/libs/java-chassis-core-2.3.6.jar!/META-INF/spring/cse.bean.xml]:
Initialization of bean failed; nested exception is
java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to
java.lang.String
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
at
org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207)
at
org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:155)
at
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:707)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533)
... 省略部分业务异常栈 ...
Caused by: java.lang.ClassCastException: java.util.LinkedHashMap cannot be
cast to java.lang.String
at
org.apache.servicecomb.config.YAMLUtil.retrieveItems(YAMLUtil.java:101)
at
org.apache.servicecomb.config.YAMLUtil.retrieveItems(YAMLUtil.java:99)
at
org.apache.servicecomb.config.YAMLUtil.retrieveItems(YAMLUtil.java:99)
at
org.apache.servicecomb.config.YAMLUtil.retrieveItems(YAMLUtil.java:99)
at
org.apache.servicecomb.config.YAMLUtil.retrieveItems(YAMLUtil.java:99)
at
org.apache.servicecomb.config.YAMLUtil.lambda$yaml2Properties$0(YAMLUtil.java:59)
at java.lang.Iterable.forEach(Iterable.java:75)
at
org.apache.servicecomb.config.YAMLUtil.yaml2Properties(YAMLUtil.java:57)
at
org.apache.servicecomb.config.archaius.sources.YAMLConfigLoader.loadData(YAMLConfigLoader.java:31)
at
org.apache.servicecomb.config.archaius.sources.AbstractConfigLoader.load(AbstractConfigLoader.java:57)
at
org.apache.servicecomb.config.archaius.sources.AbstractConfigLoader.loadFromClassPath(AbstractConfigLoader.java:51)
at
org.apache.servicecomb.config.archaius.sources.AbstractConfigLoader.load(AbstractConfigLoader.java:45)
at
org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader.loadAndSort(MicroserviceConfigLoader.java:59)
at
org.apache.servicecomb.config.ConfigUtil.createLocalConfig(ConfigUtil.java:119)
at
org.apache.servicecomb.core.ConfigurationSpringInitializer.ignoreResolveFailure(ConfigurationSpringInitializer.java:339)
at
org.apache.servicecomb.core.ConfigurationSpringInitializer.getAllProperties(ConfigurationSpringInitializer.java:295)
at
org.apache.servicecomb.core.ConfigurationSpringInitializer.syncFromSpring(ConfigurationSpringInitializer.java:149)
at
org.apache.servicecomb.core.ConfigurationSpringInitializer.setEnvironment(ConfigurationSpringInitializer.java:115)
at
org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:108)
at
org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:100)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:415)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1791)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
... 29 more
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]