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/04/09 07:35:18 UTC

[GitHub] [servicecomb-java-chassis] develpoerX opened a new issue #2349: 微服务配置文件microservice.yaml文件中配置项参数值中存在逗号时,解析成数组。

develpoerX opened a new issue #2349:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2349


   问题描述:
      微服务配置文件microservice.yaml文件中配置项参数值中存在逗号时,解析成数组。eg:在配置文件中写:
   hello:
       sayHelloPrefix: "Hello, ft"
   使用DynamicPropertyFactory.getInstance().getStringproperty(“hello.sayHelloPrefix”, "")时,获取到的结果为Hello,ft,中间空格被删除。通过定位发现,配置文件参数值,在传递过程中,会经过com.netflix.config包中的ConcurrentMapConfiguration.java文件中的addPropertyImpl(String key, Object value)解析时,默认将value中的逗号解析成数组的形式。


-- 
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:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] kaister3 commented on issue #2349: 微服务配置文件microservice.yaml文件中配置项参数值中存在逗号时,解析成数组。

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


   可以用instanceof来判断是string还是list。参考#2288


-- 
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:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] wujimin commented on issue #2349: 微服务配置文件microservice.yaml文件中配置项参数值中存在逗号时,解析成数组。

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


   getProperty时,placeholder无法发挥作用  
   可以尝试一下直接使用spirng的enviorment读取


-- 
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:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] kaister3 edited a comment on issue #2349: 微服务配置文件microservice.yaml文件中配置项参数值中存在逗号时,解析成数组。

Posted by GitBox <gi...@apache.org>.
kaister3 edited a comment on issue #2349:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2349#issuecomment-817739409


   可以用instanceof来判断是string还是list。
   
   ```java
   @SuppressWarnings("unchecked")
     public List<String> getFileSources() {
   	Object property = finalConfig.getProperty(FILE_SOURCE);
   	if (property instanceof String) {
   	  List<String> result = new ArrayList<>();
   	  result.add((String) property);
   	  return result;
   	} else if (property instanceof List) {
   	  return (List<String>) property;
   	}
   	return new ArrayList<>();
     }
   ```
   


-- 
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:
users@infra.apache.org