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 2021/07/14 08:59:36 UTC

[GitHub] [dubbo] AlbumenJ opened a new pull request #8291: Remove some local only parameters

AlbumenJ opened a new pull request #8291:
URL: https://github.com/apache/dubbo/pull/8291


   ## 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] chickenlj merged pull request #8291: Remove some local only parameters

Posted by GitBox <gi...@apache.org>.
chickenlj merged pull request #8291:
URL: https://github.com/apache/dubbo/pull/8291


   


-- 
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] chickenlj commented on a change in pull request #8291: Remove some local only parameters

Posted by GitBox <gi...@apache.org>.
chickenlj commented on a change in pull request #8291:
URL: https://github.com/apache/dubbo/pull/8291#discussion_r669437406



##########
File path: dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/AbstractDirectory.java
##########
@@ -73,32 +74,37 @@ public AbstractDirectory(URL url, RouterChain<T> routerChain, boolean isUrlFromR
 
         this.url = url.removeAttribute(REFER_KEY).removeAttribute(MONITOR_KEY);
 
-        Object referParams = url.getAttribute(REFER_KEY);
-        if (referParams != null) {
-            this.queryMap = (Map<String, String>) referParams;
-            this.consumerUrl = (URL)url.getAttribute(CONSUMER_URL_KEY);
-        } else {
-            this.queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(REFER_KEY));
-        }
+        Map<String, String> referParams = (Map<String, String>) url.getAttribute(REFER_KEY);
+        this.consumerUrl = (URL) url.getAttribute(CONSUMER_URL_KEY);
 
-        if (consumerUrl == null) {
-            String host = StringUtils.isNotEmpty(queryMap.get("register.ip")) ? queryMap.get("register.ip") : this.url.getHost();
-            String path = queryMap.get(PATH_KEY);
-            String consumedProtocol = this.queryMap.get(PROTOCOL_KEY) == null ? DUBBO : this.queryMap.get(PROTOCOL_KEY);
+        if (consumerUrl == null && referParams != null) {
+            String host = StringUtils.isNotEmpty(referParams.get("register.ip")) ? referParams.get("register.ip") : this.url.getHost();
+            String path = referParams.get(PATH_KEY);
+            String consumedProtocol = referParams.get(PROTOCOL_KEY) == null ? DUBBO : referParams.get(PROTOCOL_KEY);
 
             URL consumerUrlFrom = this.url
                     .setHost(host)
                     .setPort(0)
                     .setProtocol(consumedProtocol)
-                    .setPath(path == null ? queryMap.get(INTERFACE_KEY) : path);
+                    .setPath(path == null ? referParams.get(INTERFACE_KEY) : path);
             if (isUrlFromRegistry) {
                 // reserve parameters if url is already a consumer url
                 consumerUrlFrom = consumerUrlFrom.clearParameters();
             }
-            this.consumerUrl = consumerUrlFrom.addParameters(queryMap).removeAttribute(MONITOR_KEY);
+            this.consumerUrl = consumerUrlFrom.addParameters(referParams).removeAttribute(MONITOR_KEY);
         }
 
         setRouterChain(routerChain);
+
+        Map<String, String> queryMap;
+        if (referParams != null) {
+            queryMap = ClusterUtils.mergeLocalParams(referParams);
+        } else {
+            queryMap = ClusterUtils.mergeLocalParams(StringUtils.parseQueryString(url.getParameterAndDecoded(REFER_KEY)));
+        }
+
+        // remove some local only parameters
+        this.queryMap = ClusterUtils.mergeLocalParams(queryMap);

Review comment:
       ```java
   if (referParams != null) {
       queryMap = ClusterUtils.mergeLocalParams(referParams);
   } 
   
   
   this.queryMap = ClusterUtils.mergeLocalParams(queryMap);
   
   ```
   
   Seems like referParams will be merged twice?




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