You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/07/30 13:52:19 UTC

[GitHub] [dubbo] BurningCN opened a new pull request, #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

BurningCN opened a new pull request, #10389:
URL: https://github.com/apache/dubbo/pull/10389

   …data
   
   ## What is the purpose of the change
   
   
   
   ## Brief changelog
   
   
   ## Verifying this change
   
   
   <!-- Follow this checklist to help us incorporate your contribution quickly and easily: -->
   
   ## Checklist
   - [x] Make sure there is a [GitHub_issue](https://github.com/apache/dubbo/issues) field for the change (usually before you start working on it). Trivial changes like typos do not require a GitHub issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
   - [ ] Each commit in the pull request should have a meaningful subject line and body.
   - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [ ] Check if is necessary to patch to Dubbo 3 if you are work on Dubbo 2.7
   - [ ] Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in [dubbo samples](https://github.com/apache/dubbo-samples) project.
   - [ ] Add some description to [dubbo-website](https://github.com/apache/dubbo-website) project if you are requesting to add a feature.
   - [ ] GitHub Actions works fine on your own branch.
   - [ ] If this contribution is large, please follow the [Software Donation Guide](https://github.com/apache/dubbo/wiki/Software-donation-guide).
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933810437


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -631,7 +646,7 @@ public void overrideWithConfig(AbstractConfig newOne, boolean overrideAll) {
                         newMap.putAll(oldMap);
                     }
 
-                    invokeSetParameters(newMap, this);
+                    invokeSetParameters(this.getClass(), this, newMap);

Review Comment:
   AbstractConfig有两个`invokeSetParameters`方法,这里修改成功直接调用`三参数的invokeSetParameters`方法。
   `两参数的invokeSetParameters`内部就是获取原config的parameters 然后 newMap.putAll(parameters),但是这部分逻辑在649行上面已经处理了,不需要再在`两参数的invokeSetParameters`重复处理。



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811445


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -917,17 +936,15 @@ public String toString() {
             buf.append(getTagName(getClass()));
             for (Method method : getAttributedMethods()) {
                 try {
-                    if (MethodUtils.isGetter(method)) {

Review Comment:
   主要删除 `if (MethodUtils.isGetter(method))` ,因为该行的上面一行 `getAttributedMethods` 内部 已经做了 `isGetter` 判断



##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -917,17 +936,15 @@ public String toString() {
             buf.append(getTagName(getClass()));
             for (Method method : getAttributedMethods()) {
                 try {
-                    if (MethodUtils.isGetter(method)) {

Review Comment:
   主要删除 `if (MethodUtils.isGetter(method))` ,因为该行的上面一行 `getAttributedMethods` 内部已经做了 `isGetter` 判断



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811824


##########
dubbo-common/src/main/java/org/apache/dubbo/config/context/ConfigConfigurationAdapter.java:
##########
@@ -31,14 +30,10 @@ public class ConfigConfigurationAdapter implements Configuration {
     private Map<String, String> metaData;
 
     public ConfigConfigurationAdapter(AbstractConfig config, String prefix) {
-        Map<String, String> configMetadata = config.getMetaData();
         if (StringUtils.hasText(prefix)) {
-            metaData = new HashMap<>(configMetadata.size(), 1.0f);
-            for (Map.Entry<String, String> entry : configMetadata.entrySet()) {
-                metaData.put(prefix + "." + entry.getKey(), entry.getValue());
-            }
+            metaData = config.getMetaData(prefix);
         } else {
-            metaData = configMetadata;
+            metaData = config.getMetaData();

Review Comment:
   如果有prefix,直接调用`config.getMetaData(prefix)`,不需要像原有逻辑那样: `config.getMetaData() `+ 遍历`configMetadata`给每个entry的key拼接prefix



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811107


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -738,6 +754,19 @@ private void assignProperties(Object obj, Environment environment, Map<String, S
             } else if (isParametersSetter(method)) {
                 String propertyName = extractPropertyName(method.getName());
 
+                String value = StringUtils.trim(configuration.getString(propertyName));
+                Map<String, String> parameterMap;
+                if (StringUtils.hasText(value)) {
+                    parameterMap = StringUtils.parseParameters(value);
+                } else {
+                    // in this case, maybe parameters.item3=value3.
+                    parameterMap = ConfigurationUtils.getSubProperties(properties, PARAMETERS);
+                }
+                Map<String, String> newMap = convert(parameterMap, "");
+                if (CollectionUtils.isEmptyMap(newMap)) {
+                    continue;
+                }
+

Review Comment:
   这里是将下面红色删除的代码(即获取`newMap`的逻辑)挪到 获取`oldMap`逻辑 的上面,同时加了766~768行代码,这样当`newMap`为空的时候直接`continue`,不需要在处理后续逻辑。



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933810437


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -631,7 +646,7 @@ public void overrideWithConfig(AbstractConfig newOne, boolean overrideAll) {
                         newMap.putAll(oldMap);
                     }
 
-                    invokeSetParameters(newMap, this);
+                    invokeSetParameters(this.getClass(), this, newMap);

Review Comment:
   AbstractConfig有两个`invokeSetParameters`方法,这里修改成功直接调用`三参数的invokeSetParameters`方法。
   `两参数的invokeSetParameters`内部就是获取原config的parameters 然后 newMap.putAll(parameters),但是这部分逻辑在649行上面已经处理了,不需要再在`两参数的invokeSetParameters`重复处理。



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r934110375


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -738,6 +751,19 @@ private void assignProperties(Object obj, Environment environment, Map<String, S
             } else if (isParametersSetter(method)) {
                 String propertyName = extractPropertyName(method.getName());
 
+                String value = StringUtils.trim(configuration.getString(propertyName));
+                Map<String, String> parameterMap;
+                if (StringUtils.hasText(value)) {
+                    parameterMap = StringUtils.parseParameters(value);
+                } else {
+                    // in this case, maybe parameters.item3=value3.
+                    parameterMap = ConfigurationUtils.getSubProperties(properties, PARAMETERS);
+                }
+                Map<String, String> newMap = convert(parameterMap, "");
+                if (CollectionUtils.isEmptyMap(newMap)) {
+                    continue;
+                }
+

Review Comment:
   这里是将下面红色删除的代码(即获取`newMap`的逻辑)挪到 获取`oldMap`逻辑 的上面,同时加了766~768行代码,这样当`newMap`为空的时候直接`continue`,不需要在处理后续逻辑。



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811683


##########
dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java:
##########
@@ -234,16 +234,21 @@ protected void preProcessRefresh() {
 
     @Override
     public Map<String, String> getMetaData() {
+        return getMetaData(null);
+    }
+
+    @Override
+    public Map<String, String> getMetaData(String prefix) {

Review Comment:
   前面`AbstractConfig`的加了带有`prefix`参数的`getMetadata`重载方法,子类`ServiceConfigBase`也同步加上



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811445


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -917,17 +936,15 @@ public String toString() {
             buf.append(getTagName(getClass()));
             for (Method method : getAttributedMethods()) {
                 try {
-                    if (MethodUtils.isGetter(method)) {

Review Comment:
   主要删除 `if (MethodUtils.isGetter(method))` ,因为上面一行 `getAttributedMethods` 内部 已经做了 `isGetter` 判断



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933858753


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -514,8 +525,12 @@ protected void appendAnnotation(Class<?> annotationClass, Object annotation) {
      * @see AbstractConfig#appendParameters(Map, Object, String)
      */
     public Map<String, String> getMetaData() {
+        return getMetaData(null);
+    }
+
+    public Map<String, String> getMetaData(String prefix) {
         Map<String, String> metaData = new HashMap<>();
-        appendAttributes(metaData, this);
+        appendAttributes(metaData, this, prefix);
         return metaData;
     }

Review Comment:
   在原来`getMetaData()`的基础上,再添加一个带有`prefix`参数的重载的`getMetaData(String prefix)`方法。这样ConfigConfigurationAdapter在获取带前缀的元数据的时候直接调用此方法(`getMetaData(String prefix)`)就可以了,不需要再像原来的逻辑 `getMetaData()` + 遍历entry对每个key拼上prefix。



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811824


##########
dubbo-common/src/main/java/org/apache/dubbo/config/context/ConfigConfigurationAdapter.java:
##########
@@ -31,14 +30,10 @@ public class ConfigConfigurationAdapter implements Configuration {
     private Map<String, String> metaData;
 
     public ConfigConfigurationAdapter(AbstractConfig config, String prefix) {
-        Map<String, String> configMetadata = config.getMetaData();
         if (StringUtils.hasText(prefix)) {
-            metaData = new HashMap<>(configMetadata.size(), 1.0f);
-            for (Map.Entry<String, String> entry : configMetadata.entrySet()) {
-                metaData.put(prefix + "." + entry.getKey(), entry.getValue());
-            }
+            metaData = config.getMetaData(prefix);
         } else {
-            metaData = configMetadata;
+            metaData = config.getMetaData();

Review Comment:
   如果有`prefix`,直接调用前面新增的`config.getMetaData(prefix)`,不需要像原有逻辑那样: `config.getMetaData() `+ 遍历`configMetadata`给每个`entry`的`key`拼接`prefix`



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ merged pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
AlbumenJ merged PR #10389:
URL: https://github.com/apache/dubbo/pull/10389


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933809844


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -514,8 +525,12 @@ protected void appendAnnotation(Class<?> annotationClass, Object annotation) {
      * @see AbstractConfig#appendParameters(Map, Object, String)
      */
     public Map<String, String> getMetaData() {
+        return getMetaData(null);
+    }
+
+    public Map<String, String> getMetaData(String prefix) {
         Map<String, String> metaData = new HashMap<>();
-        appendAttributes(metaData, this);
+        appendAttributes(metaData, this, prefix);

Review Comment:
   在原来getMetaData()的基础上,再添加一个带有prefix参数的重载的getMetaData方法。这样ConfigConfigurationAdapter在获取带前缀的元数据的时候直接调用此方法(`getMetaData(String prefix)`)就可以了,不需要再像原来的逻辑 getMetaData() + 遍历entry对每个key拼上prefix。



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933810571


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -656,14 +671,15 @@ public void refresh() {
 
             // Search props starts with PREFIX in order
             String preferredPrefix = null;
-            for (String prefix : getPrefixes()) {
+            List<String> prefixes = getPrefixes();
+            for (String prefix : prefixes) {
                 if (ConfigurationUtils.hasSubProperties(configurationMaps, prefix)) {
                     preferredPrefix = prefix;
                     break;
                 }
             }
             if (preferredPrefix == null) {
-                preferredPrefix = getPrefixes().get(0);

Review Comment:
   这里和659行重复调用getPrefixes(),合成一次调用放在674行



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811107


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -738,6 +754,19 @@ private void assignProperties(Object obj, Environment environment, Map<String, S
             } else if (isParametersSetter(method)) {
                 String propertyName = extractPropertyName(method.getName());
 
+                String value = StringUtils.trim(configuration.getString(propertyName));
+                Map<String, String> parameterMap;
+                if (StringUtils.hasText(value)) {
+                    parameterMap = StringUtils.parseParameters(value);
+                } else {
+                    // in this case, maybe parameters.item3=value3.
+                    parameterMap = ConfigurationUtils.getSubProperties(properties, PARAMETERS);
+                }
+                Map<String, String> newMap = convert(parameterMap, "");
+                if (CollectionUtils.isEmptyMap(newMap)) {
+                    continue;
+                }
+

Review Comment:
   这里是将下面红色删除的代码(即获取newMap的逻辑)挪到 获取oldMap逻辑 的上面,同时加了766~768行代码,这样当newMap为空的时候直接continue,不需要在处理后续逻辑。



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r934110375


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -738,6 +751,19 @@ private void assignProperties(Object obj, Environment environment, Map<String, S
             } else if (isParametersSetter(method)) {
                 String propertyName = extractPropertyName(method.getName());
 
+                String value = StringUtils.trim(configuration.getString(propertyName));
+                Map<String, String> parameterMap;
+                if (StringUtils.hasText(value)) {
+                    parameterMap = StringUtils.parseParameters(value);
+                } else {
+                    // in this case, maybe parameters.item3=value3.
+                    parameterMap = ConfigurationUtils.getSubProperties(properties, PARAMETERS);
+                }
+                Map<String, String> newMap = convert(parameterMap, "");
+                if (CollectionUtils.isEmptyMap(newMap)) {
+                    continue;
+                }
+

Review Comment:
   这里是将下面红色删除的代码(即获取`newMap`的逻辑)挪到 获取`oldMap`逻辑 的上面,同时加了763~765行代码,这样当`newMap`为空的时候直接`continue`,不需要在处理后续逻辑。



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811369


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -776,7 +795,7 @@ private void assignProperties(Object obj, Environment environment, Map<String, S
                     oldMap.forEach(newMap::putIfAbsent);
                 }
 
-                invokeSetParameters(newMap, obj);
+                invokeSetParameters(obj.getClass(), obj, newMap);

Review Comment:
   AbstractConfig有两个`invokeSetParameters`方法,这里修改成功直接调用`三参数的invokeSetParameters`方法。
   `两参数的invokeSetParameters`内部就是获取原config的parameters 然后 newMap.putAll(parameters),但是这部分逻辑在798行上面已经处理了,不需要再在`两参数的invokeSetParameters`重复处理。



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811107


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -738,6 +754,19 @@ private void assignProperties(Object obj, Environment environment, Map<String, S
             } else if (isParametersSetter(method)) {
                 String propertyName = extractPropertyName(method.getName());
 
+                String value = StringUtils.trim(configuration.getString(propertyName));
+                Map<String, String> parameterMap;
+                if (StringUtils.hasText(value)) {
+                    parameterMap = StringUtils.parseParameters(value);
+                } else {
+                    // in this case, maybe parameters.item3=value3.
+                    parameterMap = ConfigurationUtils.getSubProperties(properties, PARAMETERS);
+                }
+                Map<String, String> newMap = convert(parameterMap, "");
+                if (CollectionUtils.isEmptyMap(newMap)) {
+                    continue;
+                }
+

Review Comment:
   这里是将下面红色删除的代码(即获取`newMap`的逻辑)挪到 获取`oldMap`逻辑 的上面,同时加了766~768行代码,这样当`newMap`为空的时候直接`continue`,不需要在处理后续逻辑。



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r934112989


##########
dubbo-common/src/main/java/org/apache/dubbo/config/context/ConfigConfigurationAdapter.java:
##########
@@ -31,14 +30,10 @@ public class ConfigConfigurationAdapter implements Configuration {
     private Map<String, String> metaData;
 
     public ConfigConfigurationAdapter(AbstractConfig config, String prefix) {
-        Map<String, String> configMetadata = config.getMetaData();
         if (StringUtils.hasText(prefix)) {
-            metaData = new HashMap<>(configMetadata.size(), 1.0f);
-            for (Map.Entry<String, String> entry : configMetadata.entrySet()) {
-                metaData.put(prefix + "." + entry.getKey(), entry.getValue());
-            }
+            metaData = config.getMetaData(prefix);

Review Comment:
   如果有`prefix`,直接调用`AbstractConfig`新增的`getMetaData(prefix)`方法,不需要像原有逻辑那样: `config.getMetaData() `+ 遍历`configMetadata`给每个`entry`的`key`拼接`prefix`



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811937


##########
dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractConfigTest.java:
##########
@@ -188,6 +191,8 @@ public void testAppendAttributes1() throws Exception {
         Assertions.assertEquals(String.valueOf(config.getNumber()), attributes.get("number"));
         Assertions.assertEquals(String.valueOf(config.getAge()), attributes.get("age"));
         Assertions.assertEquals(StringUtils.encodeParameters(config.getParameters()), attributes.get("parameters"));
+        Assertions.assertTrue(parameters.containsKey("detail.address"));// detailAddress -> detail.address
+        Assertions.assertTrue(attributes.containsKey("detail-address"));// detailAddress -> detail-address

Review Comment:
   `appendParameters`和`appendAttributes`在遇到驼峰属性名比如`detailAddress`,会生成不同结果,分别是`detail.address`和`detail-address。`



##########
dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractConfigTest.java:
##########
@@ -188,6 +191,8 @@ public void testAppendAttributes1() throws Exception {
         Assertions.assertEquals(String.valueOf(config.getNumber()), attributes.get("number"));
         Assertions.assertEquals(String.valueOf(config.getAge()), attributes.get("age"));
         Assertions.assertEquals(StringUtils.encodeParameters(config.getParameters()), attributes.get("parameters"));
+        Assertions.assertTrue(parameters.containsKey("detail.address"));// detailAddress -> detail.address
+        Assertions.assertTrue(attributes.containsKey("detail-address"));// detailAddress -> detail-address

Review Comment:
   添加case,`appendParameters`和`appendAttributes`在遇到驼峰属性名比如`detailAddress`,会生成不同结果,分别是`detail.address`和`detail-address。`



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933810571


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -656,14 +671,15 @@ public void refresh() {
 
             // Search props starts with PREFIX in order
             String preferredPrefix = null;
-            for (String prefix : getPrefixes()) {
+            List<String> prefixes = getPrefixes();
+            for (String prefix : prefixes) {
                 if (ConfigurationUtils.hasSubProperties(configurationMaps, prefix)) {
                     preferredPrefix = prefix;
                     break;
                 }
             }
             if (preferredPrefix == null) {
-                preferredPrefix = getPrefixes().get(0);

Review Comment:
   这里和659行重复调用getPrefixes(),合成一次调用放在674行



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811641


##########
dubbo-common/src/main/java/org/apache/dubbo/config/ReferenceConfigBase.java:
##########
@@ -149,15 +149,20 @@ public List<String> getPrefixes() {
 
     @Override
     public Map<String, String> getMetaData() {
+        return getMetaData(null);
+    }
+
+    @Override
+    public Map<String, String> getMetaData(String prefix) {

Review Comment:
   前面`AbstractConfig`的加了带有`prefix`参数的`getMetadata`重载方法,子类`ReferenceConfigBase`也同步加上



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811369


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -776,7 +795,7 @@ private void assignProperties(Object obj, Environment environment, Map<String, S
                     oldMap.forEach(newMap::putIfAbsent);
                 }
 
-                invokeSetParameters(newMap, obj);
+                invokeSetParameters(obj.getClass(), obj, newMap);

Review Comment:
   AbstractConfig有两个`invokeSetParameters`方法,这里修改成功直接调用`三参数的invokeSetParameters`方法。
   `两参数的invokeSetParameters`内部就是获取原config的parameters 然后 newMap.putAll(parameters),但是这部分逻辑在798行上面已经处理了,不需要再在`两参数的invokeSetParameters`重复处理。



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933812019


##########
dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractConfigTest.java:
##########
@@ -561,6 +625,13 @@ public void tetMetaData() {
         Assertions.assertEquals("override-config", metaData.get("exclude"));
         Assertions.assertNull(metaData.get("key"));
         Assertions.assertNull(metaData.get("key2"));
+
+        // with prefix
+        Map<String, String> prefixMetadata = overrideConfig.getMetaData(OverrideConfig.getTypePrefix(OverrideConfig.class));

Review Comment:
   主要测试前面新增的 `getMetaData(String prefix) `方法



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811683


##########
dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java:
##########
@@ -234,16 +234,21 @@ protected void preProcessRefresh() {
 
     @Override
     public Map<String, String> getMetaData() {
+        return getMetaData(null);
+    }
+
+    @Override
+    public Map<String, String> getMetaData(String prefix) {

Review Comment:
   前面`AbstractConfig`的加了带有`prefix`参数的`getMetadata`重载方法,子类`ServiceConfigBase`也同步加上



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933858753


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -514,8 +525,12 @@ protected void appendAnnotation(Class<?> annotationClass, Object annotation) {
      * @see AbstractConfig#appendParameters(Map, Object, String)
      */
     public Map<String, String> getMetaData() {
+        return getMetaData(null);
+    }
+
+    public Map<String, String> getMetaData(String prefix) {
         Map<String, String> metaData = new HashMap<>();
-        appendAttributes(metaData, this);
+        appendAttributes(metaData, this, prefix);
         return metaData;
     }

Review Comment:
   在原来`getMetaData()`的基础上,再添加一个带有`prefix`参数的重载的`getMetaData(String prefix)`方法。这样`ConfigConfigurationAdapter`在获取带前缀的元数据的时候直接调用此方法(`getMetaData(String prefix)`)就可以了,不需要再像原来的逻辑 `getMetaData()` + 遍历`entry`对每个`key`拼上`prefix`。



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811445


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -917,17 +936,15 @@ public String toString() {
             buf.append(getTagName(getClass()));
             for (Method method : getAttributedMethods()) {
                 try {
-                    if (MethodUtils.isGetter(method)) {

Review Comment:
   主要删除 `if (MethodUtils.isGetter(method))` ,因为该行的上面一行 `getAttributedMethods` 内部已经做了 `isGetter` 判断



##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -917,17 +933,15 @@ public String toString() {
             buf.append(getTagName(getClass()));
             for (Method method : getAttributedMethods()) {
                 try {
-                    if (MethodUtils.isGetter(method)) {

Review Comment:
   主要删除 `if (MethodUtils.isGetter(method))` ,因为该行的上面一行 `getAttributedMethods` 内部已经做了 `isGetter` 判断



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933809844


##########
dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java:
##########
@@ -514,8 +525,12 @@ protected void appendAnnotation(Class<?> annotationClass, Object annotation) {
      * @see AbstractConfig#appendParameters(Map, Object, String)
      */
     public Map<String, String> getMetaData() {
+        return getMetaData(null);
+    }
+
+    public Map<String, String> getMetaData(String prefix) {
         Map<String, String> metaData = new HashMap<>();
-        appendAttributes(metaData, this);
+        appendAttributes(metaData, this, prefix);

Review Comment:
   在原来getMetaData()的基础上,再添加一个带有prefix参数的重载的getMetaData方法。这样ConfigConfigurationAdapter在获取带前缀的元数据的时候直接调用此方法(`getMetaData(String prefix)`)就可以了,不需要再像原来的逻辑 getMetaData() + 遍历entry对每个key拼上prefix。



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811824


##########
dubbo-common/src/main/java/org/apache/dubbo/config/context/ConfigConfigurationAdapter.java:
##########
@@ -31,14 +30,10 @@ public class ConfigConfigurationAdapter implements Configuration {
     private Map<String, String> metaData;
 
     public ConfigConfigurationAdapter(AbstractConfig config, String prefix) {
-        Map<String, String> configMetadata = config.getMetaData();
         if (StringUtils.hasText(prefix)) {
-            metaData = new HashMap<>(configMetadata.size(), 1.0f);
-            for (Map.Entry<String, String> entry : configMetadata.entrySet()) {
-                metaData.put(prefix + "." + entry.getKey(), entry.getValue());
-            }
+            metaData = config.getMetaData(prefix);
         } else {
-            metaData = configMetadata;
+            metaData = config.getMetaData();

Review Comment:
   如果有`prefix`,直接调用前面新增的`config.getMetaData(prefix)`,不需要像原有逻辑那样: `config.getMetaData() `+ 遍历`configMetadata`给每个entry的key拼接prefix



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811641


##########
dubbo-common/src/main/java/org/apache/dubbo/config/ReferenceConfigBase.java:
##########
@@ -149,15 +149,20 @@ public List<String> getPrefixes() {
 
     @Override
     public Map<String, String> getMetaData() {
+        return getMetaData(null);
+    }
+
+    @Override
+    public Map<String, String> getMetaData(String prefix) {

Review Comment:
   前面`AbstractConfig`的加了带有`prefix`参数的`getMetadata`重载方法,子类`ReferenceConfigBase`也同步加上



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] codecov-commenter commented on pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#issuecomment-1200199074

   # [Codecov](https://codecov.io/gh/apache/dubbo/pull/10389?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#10389](https://codecov.io/gh/apache/dubbo/pull/10389?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (b766110) into [3.0](https://codecov.io/gh/apache/dubbo/commit/4195838c68b6b5b5d183b7d3b2dcf5e7d83d919c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (4195838) will **decrease** coverage by `0.13%`.
   > The diff coverage is `88.57%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##                3.0   #10389      +/-   ##
   ============================================
   - Coverage     65.53%   65.39%   -0.14%     
     Complexity      317      317              
   ============================================
     Files          1234     1234              
     Lines         53855    53826      -29     
     Branches       8154     8123      -31     
   ============================================
   - Hits          35292    35201      -91     
   - Misses        14679    14742      +63     
   + Partials       3884     3883       -1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dubbo/pull/10389?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...n/java/org/apache/dubbo/config/RegistryConfig.java](https://codecov.io/gh/apache/dubbo/pull/10389/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb25maWcvUmVnaXN0cnlDb25maWcuamF2YQ==) | `81.95% <ø> (ø)` | |
   | [...va/org/apache/dubbo/config/context/ConfigMode.java](https://codecov.io/gh/apache/dubbo/pull/10389/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb25maWcvY29udGV4dC9Db25maWdNb2RlLmphdmE=) | `100.00% <ø> (ø)` | |
   | [...bbo/config/context/ConfigConfigurationAdapter.java](https://codecov.io/gh/apache/dubbo/pull/10389/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb25maWcvY29udGV4dC9Db25maWdDb25maWd1cmF0aW9uQWRhcHRlci5qYXZh) | `71.42% <50.00%> (-10.39%)` | :arrow_down: |
   | [...n/java/org/apache/dubbo/config/AbstractConfig.java](https://codecov.io/gh/apache/dubbo/pull/10389/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb25maWcvQWJzdHJhY3RDb25maWcuamF2YQ==) | `81.26% <88.88%> (+4.17%)` | :arrow_up: |
   | [...a/org/apache/dubbo/config/ReferenceConfigBase.java](https://codecov.io/gh/apache/dubbo/pull/10389/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb25maWcvUmVmZXJlbmNlQ29uZmlnQmFzZS5qYXZh) | `64.49% <100.00%> (+0.25%)` | :arrow_up: |
   | [...ava/org/apache/dubbo/config/ServiceConfigBase.java](https://codecov.io/gh/apache/dubbo/pull/10389/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9jb25maWcvU2VydmljZUNvbmZpZ0Jhc2UuamF2YQ==) | `60.31% <100.00%> (+0.21%)` | :arrow_up: |
   | [...dubbo/remoting/zookeeper/ZookeeperTransporter.java](https://codecov.io/gh/apache/dubbo/pull/10389/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy96b29rZWVwZXIvWm9va2VlcGVyVHJhbnNwb3J0ZXIuamF2YQ==) | `50.00% <0.00%> (-33.34%)` | :arrow_down: |
   | [...ng/zookeeper/curator5/Curator5ZookeeperClient.java](https://codecov.io/gh/apache/dubbo/pull/10389/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3Rpbmctem9va2VlcGVyLWN1cmF0b3I1L3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy96b29rZWVwZXIvY3VyYXRvcjUvQ3VyYXRvcjVab29rZWVwZXJDbGllbnQuamF2YQ==) | `43.47% <0.00%> (-26.09%)` | :arrow_down: |
   | [.../apache/dubbo/rpc/filter/ProfilerServerFilter.java](https://codecov.io/gh/apache/dubbo/pull/10389/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tcnBjL2R1YmJvLXJwYy1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2R1YmJvL3JwYy9maWx0ZXIvUHJvZmlsZXJTZXJ2ZXJGaWx0ZXIuamF2YQ==) | `62.85% <0.00%> (-20.00%)` | :arrow_down: |
   | [...ache/dubbo/remoting/transport/AbstractChannel.java](https://codecov.io/gh/apache/dubbo/pull/10389/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHViYm8tcmVtb3RpbmcvZHViYm8tcmVtb3RpbmctYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kdWJiby9yZW1vdGluZy90cmFuc3BvcnQvQWJzdHJhY3RDaGFubmVsLmphdmE=) | `75.00% <0.00%> (-12.50%)` | :arrow_down: |
   | ... and [65 more](https://codecov.io/gh/apache/dubbo/pull/10389/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r933811824


##########
dubbo-common/src/main/java/org/apache/dubbo/config/context/ConfigConfigurationAdapter.java:
##########
@@ -31,14 +30,10 @@ public class ConfigConfigurationAdapter implements Configuration {
     private Map<String, String> metaData;
 
     public ConfigConfigurationAdapter(AbstractConfig config, String prefix) {
-        Map<String, String> configMetadata = config.getMetaData();
         if (StringUtils.hasText(prefix)) {
-            metaData = new HashMap<>(configMetadata.size(), 1.0f);
-            for (Map.Entry<String, String> entry : configMetadata.entrySet()) {
-                metaData.put(prefix + "." + entry.getKey(), entry.getValue());
-            }
+            metaData = config.getMetaData(prefix);
         } else {
-            metaData = configMetadata;
+            metaData = config.getMetaData();

Review Comment:
   如果有`prefix`,直接调用前面新增的`config.getMetaData(prefix)`,不需要像原有逻辑那样: `config.getMetaData() `+ 遍历`configMetadata`给每个`entry`的`key`拼接`prefix`



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r934111807


##########
dubbo-common/src/main/java/org/apache/dubbo/config/ServiceConfigBase.java:
##########
@@ -234,16 +234,21 @@ protected void preProcessRefresh() {
 
     @Override
     public Map<String, String> getMetaData() {
+        return getMetaData(null);
+    }
+
+    @Override
+    public Map<String, String> getMetaData(String prefix) {

Review Comment:
   前面`AbstractConfig`的加了带有`prefix`参数的`getMetadata`重载方法,子类`ServiceConfigBase`也同步加上



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] BurningCN commented on a diff in pull request #10389: Optimize the logic of ConfigConfigurationAdapter to get prefixed meta…

Posted by GitBox <gi...@apache.org>.
BurningCN commented on code in PR #10389:
URL: https://github.com/apache/dubbo/pull/10389#discussion_r934111528


##########
dubbo-common/src/main/java/org/apache/dubbo/config/ReferenceConfigBase.java:
##########
@@ -149,15 +149,20 @@ public List<String> getPrefixes() {
 
     @Override
     public Map<String, String> getMetaData() {
+        return getMetaData(null);
+    }
+
+    @Override
+    public Map<String, String> getMetaData(String prefix) {

Review Comment:
   前面`AbstractConfig`的加了带有`prefix`参数的`getMetadata`重载方法,子类`ReferenceConfigBase`也同步加上



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org