[ 
https://issues.apache.org/jira/browse/SCB-755?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16547626#comment-16547626
 ] 

ASF GitHub Bot commented on SCB-755:
------------------------------------

heyile closed pull request #818: [SCB-755] 755 Duplicate copy cse config to 
Servicecomb config
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/818
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/ConfigUtil.java
 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/ConfigUtil.java
index 21f22426d..3d8ffe537 100644
--- 
a/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/ConfigUtil.java
+++ 
b/foundations/foundation-config/src/main/java/org/apache/servicecomb/config/ConfigUtil.java
@@ -53,6 +53,7 @@
   private static final Logger LOGGER = 
LoggerFactory.getLogger(ConfigUtil.class);
 
   private static final String MICROSERVICE_CONFIG_LOADER_KEY = 
"cse-microservice-config-loader";
+  private static String DEFAULT_SOURCE_NAME = "CSE-DEFAULT-NAME";
 
   private static Map<String, Object> localConfig = new HashMap<>();
 
@@ -161,23 +162,29 @@ public static AbstractConfiguration 
convertEnvVariable(AbstractConfiguration sou
     return source;
   }
 
-  //inject a copy of servicecomb.xxx for cse.xxx
+  //主要是为了兼容老的版本
   private static void duplicateCseConfigToServicecomb(AbstractConfiguration 
source) {
-    Iterator<String> keys = source.getKeys();
-    while (keys.hasNext()) {
-      String key = keys.next();
-      if (!key.startsWith(CONFIG_CSE_PREFIX)) {
-        continue;
-      }
+    duplicateCseConfigToServicecombWithSourceName(source, DEFAULT_SOURCE_NAME);
+  }
+
 
-      String servicecombKey = CONFIG_SERVICECOMB_PREFIX + 
key.substring(key.indexOf(".") + 1);
-      if (!source.containsKey(servicecombKey)) {
-        source.addProperty(servicecombKey, source.getProperty(key));
-      } else {
-        LOGGER
-            .warn(
-                "Key {} with an ambiguous item {} exists, it's recommended to 
use only one of them.",
-                key, servicecombKey);
+  //inject a copy of servicecomb.xxx for cse.xxx
+  private static void 
duplicateCseConfigToServicecombWithSourceName(AbstractConfiguration 
source,String sourceName) {
+    if (sourceName.equals(DEFAULT_SOURCE_NAME)) {
+      Iterator<String> keys = source.getKeys();
+      while (keys.hasNext()) {
+        String key = keys.next();
+        if (!key.startsWith(CONFIG_CSE_PREFIX)) {
+          continue;
+        }
+
+        String servicecombKey = CONFIG_SERVICECOMB_PREFIX + 
key.substring(key.indexOf(".") + 1);
+        if (!source.containsKey(servicecombKey)) {
+          source.addProperty(servicecombKey, source.getProperty(key));
+        } else {
+          LOGGER.warn("Key {} with an ambiguous item {} exists, it's 
recommended to use only one of them.",
+                  key, servicecombKey);
+        }
       }
     }
   }
@@ -185,7 +192,12 @@ private static void 
duplicateCseConfigToServicecomb(AbstractConfiguration source
   private static void 
duplicateCseConfigToServicecomb(ConcurrentCompositeConfiguration 
compositeConfiguration,
       AbstractConfiguration source,
       String sourceName) {
-    duplicateCseConfigToServicecomb(source);
+
+    if (sourceName.equals("configFromYamlFile")) {
+      duplicateCseConfigToServicecombWithSourceName(source, sourceName);
+    } else {
+      duplicateCseConfigToServicecomb(source);
+    }
 
     compositeConfiguration.addConfiguration(source, sourceName);
   }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


> [SCB-755] 755 Duplicate copy cse config to Servicecomb config
> -------------------------------------------------------------
>
>                 Key: SCB-755
>                 URL: https://issues.apache.org/jira/browse/SCB-755
>             Project: Apache ServiceComb
>          Issue Type: Improvement
>          Components: Java-Chassis
>            Reporter: 何一乐
>            Priority: Minor
>
> [main           ] WARN  Key cse.tcc.transaction.redis.host with an ambiguous 
> item servicecomb.tcc.transaction.redis.host exists, it's recommended to use 
> only one of them. 
> [org.apache.servicecomb.config.ConfigUtil.duplicateCseConfigToServicecomb(ConfigUtil.java:178)]
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to