You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/12/07 10:06:07 UTC

[GitHub] [servicecomb-java-chassis] yhs0092 opened a new issue #2657: 建议优化microservice.yaml配置文件加载的日志

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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] develpoerX commented on issue #2657: 建议优化microservice.yaml配置文件加载的日志

Posted by GitBox <gi...@apache.org>.
develpoerX commented on issue #2657:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2657#issuecomment-988532346


   可以考虑增加一个日志打印,和debug级别日志


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] yhs0092 commented on issue #2657: 建议优化microservice.yaml配置文件加载的日志

Posted by GitBox <gi...@apache.org>.
yhs0092 commented on issue #2657:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2657#issuecomment-988541590


   > 可以考虑增加一个日志打印,和debug级别日志
   
   debug级别的日志, 大多数业务默认不会开, 不太实用. 而microservice.yaml文件列表对Java-Chassis框架问题定位又很重要. 既然Java-Chassis 现在就会把 microservice.yaml 文件列表打出来, 能否调整一下日志位置, 提前打, 这样就不会受异常击穿影响了.
   
   再就是能否看一下在`YAMLUtil`的某个方法里增加try catch, 一旦碰到这种文件读取失败, 打出具体是哪个文件有问题呢.


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2657: 建议优化microservice.yaml配置文件加载的日志

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2657:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2657#issuecomment-1057613376


   https://github.com/apache/servicecomb-java-chassis/pull/2688


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 closed issue #2657: 建议优化microservice.yaml配置文件加载的日志

Posted by GitBox <gi...@apache.org>.
liubao68 closed issue #2657:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2657


   


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org