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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to