alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
27.83k stars 8.31k forks source link

empty config at nacos-server make a exception java.util.ConcurrentModificationException: null #747

Closed Comven closed 5 years ago

Comven commented 5 years ago

nacos 1.0.0 spring-cloud Greenwich SR1

When the configuration center address is configured in the program after spring.cloud.nacos.config.server-addr, there is a sudden such problem at 1 am on the 15th. `[fixed-127.0.0.1_8848] [sub-server] get server config exception, dataId=xxx-center.properties, group=DEFAULT_GROUP, tenant=

java.net.ConnectException: no available server`

I think it may be because the configuration center address is configured, but there is a relationship that increases the corresponding configuration. So after adding a configuration xxx-center.properies to the nacos server configuration list, since it is not allowed to directly publish empty files, a parameter test=1 is randomly configured. Then when I started the xxx-center program, I reported the error directly and the program hangs. The error is as follows: java.util.ConcurrentModificationException: null at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:909) at java.util.ArrayList$Itr.next(ArrayList.java:859) at org.springframework.cloud.netflix.ribbon.RibbonApplicationContextInitializer.initialize(RibbonApplicationContextInitializer.java:46) at org.springframework.cloud.netflix.ribbon.RibbonApplicationContextInitializer.onApplicationEvent(RibbonApplicationContextInitializer.java:54) at org.springframework.cloud.netflix.ribbon.RibbonApplicationContextInitializer.onApplicationEvent(RibbonApplicationContextInitializer.java:30) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359) at org.springframework.boot.context.event.EventPublishingRunListener.running(EventPublishingRunListener.java:105) at org.springframework.boot.SpringApplicationRunListeners.running(SpringApplicationRunListeners.java:78) at org.springframework.boot.SpringApplication.run(SpringApplication.java:332) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) According to the prompt to find the RibbonApplicationContextInitializer found in the following code protected void initialize() { if (clientNames != null) { for (String clientName : clientNames) { this.springClientFactory.getContext(clientName); } } } The element value of clientNames was changed to null during the initialization process, because I used the ribbon.eager-load load configuration in my program and reported the exception initialized by this ribbon.

When I delete the xxx.properties of the nacos server, the program will start normally.

Is this a bug in spring-cloud-alibaba components?

flystar32 commented 5 years ago

I can't get precise information from your describe.

  1. no available server seems to can't connect to Nacos Server.
  2. I don't think configuration with content 'test=1' would cause ribbon eager load error.

Provide a project that reproduces the issue would helps a lot.

Comven commented 5 years ago

我用中文描述一下,当我在nacos-server配置列表中配置一个配置假如叫user-center.properties,然后我的应用程序中加入了ribbon eager配置 ` ribbon.eager-load.enabled=true

ribbon.eager-load.clients=cryption-center ` 我的cryption-center程序是存在且注册成功的。这个时候我启动user-center程序会导致上面的错,我当时测试的nacos-server和nacos-client版本为1.0.0,按照ribbon eager的配置不采用nacos做注册中心的时候,及时需要执行eager-load的服务不可达,程序也不回挂掉,而采用nacos后会打印上面的错,最后程序启动不成功。但是当时我们没有去验证是否cryption-center是不可达状态,因为我反复重启了多次cryption-center和user-center程序,当时我将issue提到了nacos项目组,https://github.com/alibaba/nacos/issues/1383

我今天升级了nacos到1.1.0之后,暂时未再出现这个问题。稍后如果再次重现,我再来提吧。

chengqipeng commented 5 years ago

springcloud项目里面如何引入最新的版本啊

Comven commented 5 years ago

springcloud项目里面如何引入最新的版本啊

你是想使用最新版本的nacos-client吗 处理下你的依赖就行了


       <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>nacos-client</artifactId>
                    <groupId>com.alibaba.nacos</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>nacos-client</artifactId>
                    <groupId>com.alibaba.nacos</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.alibaba.nacos</groupId>
            <artifactId>nacos-client</artifactId>
            <version>[1.1.0,)</version>
        </dependency>