zhangchi02 opened a new issue #1501: SpringBoot+CSE开发的微服务,通过配置文件获取配置有问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1501
 
 
   1. 在microservice.yaml中配置CSE_SERVERURI: 
https://172.16.2.236:30103,https://172.16.2.47:30103,并用${CSE_SERVERURI}取值,只获取到第一个地址
   
![image](https://user-images.githubusercontent.com/27462770/71445772-9691d880-2757-11ea-9153-ada6e88eb00d.png)
   
经过debug发现是org.apache.commons.configuration.AbstractConfiguration#resolveContainerStore方法只取了第一个值
   
![image](https://user-images.githubusercontent.com/27462770/71541689-d6470300-2997-11ea-8043-236613e6b625.png)
   
![image](https://user-images.githubusercontent.com/27462770/71541693-e363f200-2997-11ea-920e-fa0b8f619b65.png)
   
   2. 在application.yaml中配置CSE_SERVERURI: 
https://172.16.2.236:30103,https://172.16.2.47:30103,在microservice.yaml中用${CSE_SERVERURI}取值,取到两个地址拼接的字符串.
 
   
![image](https://user-images.githubusercontent.com/27462770/71445793-c3de8680-2757-11ea-8df1-a7560fa0578d.png)
   这样就导致解析uri获取host的时候报错
   ERROR 9024 --- [ntloop-thread-0] io.vertx.core.impl.ContextImpl           : 
Unhandled exception
   
   java.lang.IllegalArgumentException: Illegal uri: 
[https://172.16.2.236:30103,https://172.16.2.47:30103]
        at 
org.apache.servicecomb.foundation.common.net.NetUtils.parseIpPort(NetUtils.java:170)
 ~[foundation-common-1.2.0.B011.jar:1.2.0.B011]
        at 
org.apache.servicecomb.foundation.common.net.NetUtils.parseIpPort(NetUtils.java:156)
 ~[foundation-common-1.2.0.B011.jar:1.2.0.B011]
        at 
org.apache.servicecomb.foundation.common.net.NetUtils.parseIpPortFromURI(NetUtils.java:198)
 ~[foundation-common-1.2.0.B011.jar:1.2.0.B011]
        at 
org.apache.servicecomb.config.client.ConfigCenterClient$ConfigRefresh.lambda$refreshConfig$14(ConfigCenterClient.java:379)
 ~[config-cc-1.2.0.B011.jar:1.2.0.B011]
        at 
org.apache.servicecomb.foundation.vertx.client.http.HttpClientWithContext.lambda$runOnContext$0(HttpClientWithContext.java:43)
 ~[foundation-vertx-1.2.0.B011.jar:1.2.0.B011]
        at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:320) 
~[vertx-core-3.6.3.jar:3.6.3]
        at 
io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38)
 [vertx-core-3.6.3.jar:3.6.3]
        at 
io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:163)
 ~[netty-common-4.1.42.Final.jar:4.1.42.Final]
        at 
io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java)
 ~[netty-common-4.1.42.Final.jar:4.1.42.Final]
        at 
io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:510)
 ~[netty-common-4.1.42.Final.jar:4.1.42.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:518) 
~[netty-transport-4.1.42.Final.jar:4.1.42.Final]
        at 
io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1044)
 ~[netty-common-4.1.42.Final.jar:4.1.42.Final]
        at 
io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) 
~[netty-common-4.1.42.Final.jar:4.1.42.Final]
        at 
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
 ~[netty-common-4.1.42.Final.jar:4.1.42.Final]
        at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_144]
   
   
经过debug后发现是在org.apache.servicecomb.config.ConfigurationSpringInitializer#setEnvironment该处设置的值,而从application.yaml取值是spring的逻辑,这样ServiceComb拿到的就是一个长字符串并直接使用了,这就导致了上述报错。
   
![image](https://user-images.githubusercontent.com/27462770/71541627-04781300-2997-11ea-9faf-a4d48759014e.png)
   
   
   3. 直接在microservice.yaml文件中配置 
https://172.16.2.236:30103,https://172.16.2.47:30103,可以正常取值
   
![image](https://user-images.githubusercontent.com/27462770/71445847-6bf44f80-2758-11ea-8037-1cbf090686b4.png)
   4. 通过Java System 
Property设置参数-Dcse.config.client.serverUri=https://127.0.0.1:30103,https://127.0.0.1:30103也是没有问题的
   
![image](https://user-images.githubusercontent.com/27462770/71445870-98a86700-2758-11ea-8f3f-8fb1f9247e62.png)
   5. 
通过环境变量配置PAAS_CSE_CC_ENDPOINT=https://127.0.0.3:30103,https://127.0.0.4:30103,不会走org.apache.servicecomb.deployment.DefaultDeploymentProvider#getSystemBootStrapInfo方法,结果也是正常的
   
![image](https://user-images.githubusercontent.com/27462770/71445878-afe75480-2758-11ea-8cfd-33e0ba49e638.png)
   
   想问一下,1,2两种情况下,该怎么处理?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to