nacos-group / nacos-spring-boot-project

Nacos ECO Project for Spring Boot
Apache License 2.0
789 stars 424 forks source link

可选优化点 com.alibaba.boot.nacos.config.util.NacosConfigLoader#reqNacosConfig #301

Closed gMan1990 closed 9 months ago

gMan1990 commented 1 year ago

https://github.com/nacos-group/nacos-spring-boot-project/blob/82caa209b37f785980526b394f3def17bb84458f/nacos-config-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/nacos/config/util/NacosConfigLoader.java#L150

  1. 假设用户配置的 nacos.config.data-ids=a,,b 写错了,多写了个,
  2. final NacosPropertySource[] propertySources = new NacosPropertySource[dataIds.length];
  3. propertySources 的长度 是 3
  4. for 里会进入 continue 导致 propertySources 里有一个 null
java.lang.NullPointerException: Cannot invoke "org.springframework.core.env.PropertySource.getName()" because "propertySource" is null
at org.springframework.core.env.PropertySourcesPropertyResolver.getProperty(PropertySourcesPropertyResolver.java:85)
hujun-w-2 commented 9 months ago

321 已修复