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/14 05:33:34 UTC

[GitHub] [dubbo] EarthChen commented on a diff in pull request #10313: refactor parameter on consumer url logic code

EarthChen commented on code in PR #10313:
URL: https://github.com/apache/dubbo/pull/10313#discussion_r920766067


##########
dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/InstanceAddressURL.java:
##########
@@ -343,37 +312,91 @@ public boolean hasMethodParameter(String method, String key) {
      * @return
      */
     @Override
-    public boolean hasServiceMethodParameter(String protocolServiceKey, String method) {
-        URL consumerUrl = RpcContext.getServiceContext().getConsumerUrl();
-        if (consumerUrl != null) {
-            if (consumerUrl.hasServiceMethodParameter(protocolServiceKey, method)) {
-                return true;
-            }
+    public boolean hasServiceMethodParameter(final String protocolServiceKey, final String method) {
+        if (hasParameterOnConsumerUrl(ParameterOnConsumerUrl.ServiceMethodParameter, protocolServiceKey, method, null, false)) {
+            return true;
         }
-
         MetadataInfo.ServiceInfo serviceInfo = getServiceInfo(protocolServiceKey);
         if (null == serviceInfo) {
             return false;
         }
-
         return serviceInfo.hasMethodParameter(method);
     }
 
     @Override
-    public boolean hasMethodParameter(String method) {
-        URL consumerUrl = RpcContext.getServiceContext().getConsumerUrl();
-        if (consumerUrl != null) {
-            if (consumerUrl.hasMethodParameter(method)) {
-                return true;
-            }
+    public boolean hasMethodParameter(final String method) {
+        if (hasParameterOnConsumerUrl(ParameterOnConsumerUrl.MethodParameter, null, method, null, false)) {
+            return true;
         }
-
         String protocolServiceKey = getProtocolServiceKey();
         if (isEmpty(protocolServiceKey)) {
             return false;
         }
         return hasServiceMethodParameter(protocolServiceKey, method);
     }
+    
+    private String getParameterOnConsumerUrl(final ParameterOnConsumerUrl parameterOnConsumerUrl, final URL consumerUrl,

Review Comment:
   replace `if return` is better.



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