This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.0 by this push:
     new a9d3c4a  [3.0]Refactor reference config (#8455)
a9d3c4a is described below

commit a9d3c4a77fde41c3c90217f836574cc3cd990e8a
Author: huazhongming <[email protected]>
AuthorDate: Sun Aug 15 22:23:03 2021 +0800

    [3.0]Refactor reference config (#8455)
    
    * refactor referenceConfig
    
    * fix
    
    * fix
    
    * fix
    
    * change refer process
    
    * fix
    
    * fix import
    
    * fix
    
    * fix npe
---
 .../org/apache/dubbo/config/AbstractConfig.java    |  91 ++----
 .../dubbo/config/AbstractInterfaceConfig.java      |   4 +-
 .../java/org/apache/dubbo/config/MethodConfig.java |  52 +++-
 .../apache/dubbo/config/ReferenceConfigBase.java   |   4 +-
 .../org/apache/dubbo/rpc/model/ConsumerModel.java  |  55 ++--
 .../apache/dubbo/rpc/model/ServiceRepository.java  |  12 +-
 .../org/apache/dubbo/config/MethodConfigTest.java  |   2 +-
 .../org/apache/dubbo/config/ReferenceConfig.java   | 338 ++++++++++++---------
 .../registry/integration/RegistryProtocol.java     |   2 +-
 .../dubbo/rpc/protocol/grpc/GrpcProtocolTest.java  |   9 +-
 10 files changed, 317 insertions(+), 252 deletions(-)

diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java 
b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java
index 4759237..1d685c9 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractConfig.java
@@ -30,7 +30,6 @@ import org.apache.dubbo.common.utils.ReflectUtils;
 import org.apache.dubbo.common.utils.StringUtils;
 import org.apache.dubbo.config.support.Parameter;
 import org.apache.dubbo.rpc.model.ApplicationModel;
-import org.apache.dubbo.rpc.model.AsyncMethodInfo;
 
 import java.beans.BeanInfo;
 import java.beans.IntrospectionException;
@@ -96,7 +95,7 @@ public abstract class AbstractConfig implements Serializable {
 
 
     public static String getTagName(Class<?> cls) {
-        return tagNameCache.computeIfAbsent(cls, (key)-> {
+        return tagNameCache.computeIfAbsent(cls, (key) -> {
             String tag = cls.getSimpleName();
             for (String suffix : SUFFIXES) {
                 if (tag.endsWith(suffix)) {
@@ -131,6 +130,7 @@ public abstract class AbstractConfig implements 
Serializable {
 
     /**
      * Put attributes of specify 'config' into 'parameters' argument
+     *
      * @param parameters
      * @param config
      */
@@ -154,7 +154,7 @@ public abstract class AbstractConfig implements 
Serializable {
             try {
                 String name = method.getName();
                 if (MethodUtils.isGetter(method)) {
-                    if (method.getReturnType() == Object.class ) {
+                    if (method.getReturnType() == Object.class) {
                         continue;
                     }
                     String key = calculatePropertyFromGetter(name);
@@ -215,52 +215,6 @@ public abstract class AbstractConfig implements 
Serializable {
         }
     }
 
-    protected static AsyncMethodInfo 
convertMethodConfig2AsyncInfo(MethodConfig methodConfig) {
-        if (methodConfig == null || (methodConfig.getOninvoke() == null && 
methodConfig.getOnreturn() == null && methodConfig.getOnthrow() == null)) {
-            return null;
-        }
-
-        //check config conflict
-        if (Boolean.FALSE.equals(methodConfig.isReturn()) && 
(methodConfig.getOnreturn() != null || methodConfig.getOnthrow() != null)) {
-            throw new IllegalStateException("method config error : return 
attribute must be set true when onreturn or onthrow has been set.");
-        }
-
-        AsyncMethodInfo asyncMethodInfo = new AsyncMethodInfo();
-
-        asyncMethodInfo.setOninvokeInstance(methodConfig.getOninvoke());
-        asyncMethodInfo.setOnreturnInstance(methodConfig.getOnreturn());
-        asyncMethodInfo.setOnthrowInstance(methodConfig.getOnthrow());
-
-        try {
-            String oninvokeMethod = methodConfig.getOninvokeMethod();
-            if (StringUtils.isNotEmpty(oninvokeMethod)) {
-                
asyncMethodInfo.setOninvokeMethod(getMethodByName(methodConfig.getOninvoke().getClass(),
 oninvokeMethod));
-            }
-
-            String onreturnMethod = methodConfig.getOnreturnMethod();
-            if (StringUtils.isNotEmpty(onreturnMethod)) {
-                
asyncMethodInfo.setOnreturnMethod(getMethodByName(methodConfig.getOnreturn().getClass(),
 onreturnMethod));
-            }
-
-            String onthrowMethod = methodConfig.getOnthrowMethod();
-            if (StringUtils.isNotEmpty(onthrowMethod)) {
-                
asyncMethodInfo.setOnthrowMethod(getMethodByName(methodConfig.getOnthrow().getClass(),
 onthrowMethod));
-            }
-        } catch (Exception e) {
-            throw new IllegalStateException(e.getMessage(), e);
-        }
-
-        return asyncMethodInfo;
-    }
-
-    private static Method getMethodByName(Class<?> clazz, String methodName) {
-        try {
-            return ReflectUtils.findMethodByMethodName(clazz, methodName);
-        } catch (Exception e) {
-            throw new IllegalStateException(e);
-        }
-    }
-
     protected static Set<String> getSubProperties(Map<String, String> 
properties, String prefix) {
         return properties.keySet().stream().filter(k -> 
k.contains(prefix)).map(k -> {
             k = k.substring(prefix.length());
@@ -310,17 +264,17 @@ public abstract class AbstractConfig implements 
Serializable {
     private static boolean isParametersGetter(Method method) {
         String name = method.getName();
         return ("getParameters".equals(name)
-                && Modifier.isPublic(method.getModifiers())
-                && method.getParameterTypes().length == 0
-                && method.getReturnType() == Map.class);
+            && Modifier.isPublic(method.getModifiers())
+            && method.getParameterTypes().length == 0
+            && method.getReturnType() == Map.class);
     }
 
     private static boolean isParametersSetter(Method method) {
         return ("setParameters".equals(method.getName())
-                && Modifier.isPublic(method.getModifiers())
-                && method.getParameterCount() == 1
-                && Map.class == method.getParameterTypes()[0]
-                && method.getReturnType() == void.class);
+            && Modifier.isPublic(method.getModifiers())
+            && method.getParameterCount() == 1
+            && Map.class == method.getParameterTypes()[0]
+            && method.getReturnType() == void.class);
     }
 
     /**
@@ -365,6 +319,7 @@ public abstract class AbstractConfig implements 
Serializable {
 
     /**
      * Copy attributes from annotation
+     *
      * @param annotationClass
      * @param annotation
      */
@@ -372,11 +327,11 @@ public abstract class AbstractConfig implements 
Serializable {
         Method[] methods = annotationClass.getMethods();
         for (Method method : methods) {
             if (method.getDeclaringClass() != Object.class
-                    && method.getDeclaringClass()!= Annotation.class
-                    && method.getReturnType() != void.class
-                    && method.getParameterTypes().length == 0
-                    && Modifier.isPublic(method.getModifiers())
-                    && !Modifier.isStatic(method.getModifiers())) {
+                && method.getDeclaringClass() != Annotation.class
+                && method.getReturnType() != void.class
+                && method.getParameterTypes().length == 0
+                && Modifier.isPublic(method.getModifiers())
+                && !Modifier.isStatic(method.getModifiers())) {
                 try {
                     String property = method.getName();
                     if ("interfaceClass".equals(property) || 
"interfaceName".equals(property)) {
@@ -408,7 +363,6 @@ public abstract class AbstractConfig implements 
Serializable {
     }
 
     /**
-     *
      * <p>
      * <b>The new instance of the AbstractConfig subclass should return empty 
metadata.</b>
      * The purpose is is to get the attributes set by the user instead of the 
default value when the {@link #refresh()} method handles attribute overrides.
@@ -535,14 +489,14 @@ public abstract class AbstractConfig implements 
Serializable {
                         String value = 
StringUtils.trim(subPropsConfiguration.getString(kebabPropertyName));
                         // isTypeMatch() is called to avoid duplicate and 
incorrect update, for example, we have two 'setGeneric' methods in 
ReferenceConfig.
                         if (StringUtils.hasText(value) && 
ClassUtils.isTypeMatch(method.getParameterTypes()[0], value) &&
-                                !isIgnoredAttribute(getClass(), propertyName)) 
{
+                            !isIgnoredAttribute(getClass(), propertyName)) {
                             value = environment.resolvePlaceholders(value);
                             method.invoke(this, 
ClassUtils.convertPrimitive(method.getParameterTypes()[0], value));
                         }
                     } catch (Exception e) {
                         logger.info("Failed to override the property " + 
method.getName() + " in " +
-                                this.getClass().getSimpleName() +
-                                ", please make sure every property has 
getter/setter method provided.");
+                            this.getClass().getSimpleName() +
+                            ", please make sure every property has 
getter/setter method provided.");
                     }
                 } else if (isParametersSetter(method)) {
                     String propertyName = 
extractPropertyName(method.getName());
@@ -562,8 +516,8 @@ public abstract class AbstractConfig implements 
Serializable {
             processExtraRefresh(preferredPrefix, subPropsConfiguration);
 
         } catch (Exception e) {
-            logger.error("Failed to override field value of config bean: 
"+this, e);
-            throw new IllegalStateException("Failed to override field value of 
config bean: "+this, e);
+            logger.error("Failed to override field value of config bean: " + 
this, e);
+            throw new IllegalStateException("Failed to override field value of 
config bean: " + this, e);
         }
 
         postProcessRefresh();
@@ -744,11 +698,12 @@ public abstract class AbstractConfig implements 
Serializable {
 
     private List<Method> getAttributedMethods() {
         Class<? extends AbstractConfig> cls = this.getClass();
-        return attributedMethodCache.computeIfAbsent(cls, (key)-> 
computeAttributedMethods());
+        return attributedMethodCache.computeIfAbsent(cls, (key) -> 
computeAttributedMethods());
     }
 
     /**
      * compute attributed getter methods, subclass can override this method to 
add/remove attributed methods
+     *
      * @return
      */
     protected List<Method> computeAttributedMethods() {
diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
 
b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
index 3bc224b..cd9fdda 100644
--- 
a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
+++ 
b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
@@ -90,7 +90,7 @@ public abstract class AbstractInterfaceConfig extends 
AbstractMethodConfig {
     protected MonitorConfig monitor;
 
     /**
-     * Strategies for generating dynamic agents,there are two strategies can 
be choosed: jdk and javassist
+     * Strategies for generating dynamic agents,there are two strategies can 
be chosen: jdk and javassist
      */
     protected String proxy;
 
@@ -227,7 +227,7 @@ public abstract class AbstractInterfaceConfig extends 
AbstractMethodConfig {
     protected String[] methods(Class<?> interfaceClass) {
         boolean isNative = 
ApplicationModel.getEnvironment().getConfiguration().getBoolean(NATIVE, false);
         if (isNative) {
-            return Arrays.stream(interfaceClass.getMethods()).map(it -> 
it.getName()).toArray(String[]::new);
+            return 
Arrays.stream(interfaceClass.getMethods()).map(Method::getName).toArray(String[]::new);
         } else {
             return Wrapper.getWrapper(interfaceClass).getMethodNames();
         }
diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/config/MethodConfig.java 
b/dubbo-common/src/main/java/org/apache/dubbo/config/MethodConfig.java
index 8dde37b..2210d6d 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/config/MethodConfig.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/config/MethodConfig.java
@@ -20,10 +20,12 @@ import org.apache.dubbo.common.config.Environment;
 import org.apache.dubbo.common.config.InmemoryConfiguration;
 import org.apache.dubbo.common.utils.ClassUtils;
 import org.apache.dubbo.common.utils.MethodUtils;
+import org.apache.dubbo.common.utils.ReflectUtils;
 import org.apache.dubbo.common.utils.StringUtils;
 import org.apache.dubbo.config.annotation.Method;
 import org.apache.dubbo.config.support.Parameter;
 import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.rpc.model.AsyncMethodInfo;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -181,13 +183,14 @@ public class MethodConfig extends AbstractMethodConfig {
 
     /**
      * TODO remove constructMethodConfig
+     *
      * @param methods
      * @return
      */
     @Deprecated
     public static List<MethodConfig> constructMethodConfig(Method[] methods) {
         if (methods != null && methods.length != 0) {
-            List<MethodConfig> methodConfigs = new 
ArrayList<MethodConfig>(methods.length);
+            List<MethodConfig> methodConfigs = new ArrayList<>(methods.length);
             for (int i = 0; i < methods.length; i++) {
                 MethodConfig methodConfig = new MethodConfig(methods[i]);
                 methodConfigs.add(methodConfig);
@@ -199,6 +202,7 @@ public class MethodConfig extends AbstractMethodConfig {
 
     /**
      * Get method prefixes
+     *
      * @return
      */
     @Override
@@ -207,7 +211,7 @@ public class MethodConfig extends AbstractMethodConfig {
         // parent prefix + method name
         if (parentPrefix != null) {
             List<String> prefixes = new ArrayList<>();
-            prefixes.add(parentPrefix + "." +this.getName());
+            prefixes.add(parentPrefix + "." + this.getName());
             return prefixes;
         } else {
             throw new IllegalStateException("The parent prefix of MethodConfig 
is null");
@@ -256,6 +260,50 @@ public class MethodConfig extends AbstractMethodConfig {
         }
     }
 
+
+    public AsyncMethodInfo convertMethodConfig2AsyncInfo() {
+        if ((getOninvoke() == null && getOnreturn() == null && getOnthrow() == 
null)) {
+            return null;
+        }
+
+        //check config conflict
+        if (Boolean.FALSE.equals(isReturn()) && (getOnreturn() != null || 
getOnthrow() != null)) {
+            throw new IllegalStateException("method config error : return 
attribute must be set true when on-return or on-throw has been set.");
+        }
+
+        AsyncMethodInfo asyncMethodInfo = new AsyncMethodInfo();
+
+        asyncMethodInfo.setOninvokeInstance(getOninvoke());
+        asyncMethodInfo.setOnreturnInstance(getOnreturn());
+        asyncMethodInfo.setOnthrowInstance(getOnthrow());
+
+        try {
+            if (StringUtils.isNotEmpty(oninvokeMethod)) {
+                
asyncMethodInfo.setOninvokeMethod(getMethodByName(getOninvoke().getClass(), 
oninvokeMethod));
+            }
+
+            if (StringUtils.isNotEmpty(onreturnMethod)) {
+                
asyncMethodInfo.setOnreturnMethod(getMethodByName(getOnreturn().getClass(), 
onreturnMethod));
+            }
+
+            if (StringUtils.isNotEmpty(onthrowMethod)) {
+                
asyncMethodInfo.setOnthrowMethod(getMethodByName(getOnthrow().getClass(), 
onthrowMethod));
+            }
+        } catch (Exception e) {
+            throw new IllegalStateException(e.getMessage(), e);
+        }
+
+        return asyncMethodInfo;
+    }
+
+    private java.lang.reflect.Method getMethodByName(Class<?> clazz, String 
methodName) {
+        try {
+            return ReflectUtils.findMethodByMethodName(clazz, methodName);
+        } catch (Exception e) {
+            throw new IllegalStateException(e);
+        }
+    }
+
     /**
      * Set default field values of MethodConfig.
      *
diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/config/ReferenceConfigBase.java 
b/dubbo-common/src/main/java/org/apache/dubbo/config/ReferenceConfigBase.java
index 28d462b..88e9b2a 100644
--- 
a/dubbo-common/src/main/java/org/apache/dubbo/config/ReferenceConfigBase.java
+++ 
b/dubbo-common/src/main/java/org/apache/dubbo/config/ReferenceConfigBase.java
@@ -134,7 +134,7 @@ public abstract class ReferenceConfigBase<T> extends 
AbstractReferenceConfig {
     public Map<String, String> getMetaData() {
         Map<String, String> metaData = new HashMap<>();
         ConsumerConfig consumer = this.getConsumer();
-        // consumer should be inited at preProcessRefresh()
+        // consumer should be initialized at preProcessRefresh()
         if (isRefreshed() && consumer == null) {
             throw new IllegalStateException("Consumer is not initialized");
         }
@@ -150,7 +150,7 @@ public abstract class ReferenceConfigBase<T> extends 
AbstractReferenceConfig {
      * @return
      */
     public Class<?> getServiceInterfaceClass() {
-        Class actualInterface = interfaceClass;
+        Class<?> actualInterface = interfaceClass;
         if (interfaceClass == GenericService.class) {
             try {
                 actualInterface = Class.forName(interfaceName);
diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ConsumerModel.java 
b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ConsumerModel.java
index ce4ab6a..81b1a88 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ConsumerModel.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ConsumerModel.java
@@ -42,19 +42,21 @@ public class ConsumerModel {
 
     private Object proxyObject;
 
-    private Map<String, AsyncMethodInfo> methodConfigs = new HashMap<>();
+    private final Map<String, AsyncMethodInfo> methodConfigs;
 
     /**
-     *  This constructor create an instance of ConsumerModel and passed 
objects should not be null.
-     *  If service name, service instance, proxy object,methods should not be 
null. If these are null
-     *  then this constructor will throw {@link IllegalArgumentException}
-     * @param serviceKey Name of the service.
-     * @param proxyObject  Proxy object.
+     * This constructor create an instance of ConsumerModel and passed objects 
should not be null.
+     * If service name, service instance, proxy object,methods should not be 
null. If these are null
+     * then this constructor will throw {@link IllegalArgumentException}
+     *
+     * @param serviceKey  Name of the service.
+     * @param proxyObject Proxy object.
      */
-    public ConsumerModel(String serviceKey
-            , Object proxyObject
-            , ServiceDescriptor serviceModel
-            , ReferenceConfigBase<?> referenceConfig) {
+    public ConsumerModel(String serviceKey,
+                         Object proxyObject,
+                         ServiceDescriptor serviceModel,
+                         ReferenceConfigBase<?> referenceConfig,
+                         Map<String, AsyncMethodInfo> methodConfigs) {
 
         Assert.notEmptyString(serviceKey, "Service name can't be null or 
blank");
 
@@ -62,18 +64,12 @@ public class ConsumerModel {
         this.proxyObject = proxyObject;
         this.serviceModel = serviceModel;
         this.referenceConfig = referenceConfig;
-    }
-
-    public void init(Map<String, AsyncMethodInfo> attributes) {
-        if (attributes != null) {
-            this.methodConfigs = attributes;
-        }
-
-        initMethodModels();
+        this.methodConfigs = methodConfigs == null ? new HashMap<>() : 
methodConfigs;
     }
 
     /**
      * Return the proxy object used by called while creating instance of 
ConsumerModel
+     *
      * @return
      */
     public Object getProxyObject() {
@@ -126,13 +122,14 @@ public class ConsumerModel {
     private ServiceMetadata serviceMetadata;
     private Map<Method, ConsumerMethodModel> methodModels = new HashMap<>();
 
-    public ConsumerModel(String serviceKey
-            , Object proxyObject
-            , ServiceDescriptor serviceModel
-            , ReferenceConfigBase<?> referenceConfig
-            , ServiceMetadata metadata) {
+    public ConsumerModel(String serviceKey,
+                         Object proxyObject,
+                         ServiceDescriptor serviceModel,
+                         ReferenceConfigBase<?> referenceConfig,
+                         ServiceMetadata metadata,
+                         Map<String, AsyncMethodInfo> methodConfigs) {
 
-        this(serviceKey, proxyObject, serviceModel, referenceConfig);
+        this(serviceKey, proxyObject, serviceModel, referenceConfig, 
methodConfigs);
         this.serviceMetadata = metadata;
     }
 
@@ -145,7 +142,7 @@ public class ConsumerModel {
     }
 
     public void initMethodModels() {
-        Class[] interfaceList = null;
+        Class<?>[] interfaceList;
         if (proxyObject == null) {
             Class<?> serviceInterfaceClass = 
referenceConfig.getServiceInterfaceClass();
             if (serviceInterfaceClass != null) {
@@ -156,7 +153,7 @@ public class ConsumerModel {
         } else {
             interfaceList = proxyObject.getClass().getInterfaces();
         }
-        for (Class interfaceClass : interfaceList) {
+        for (Class<?> interfaceClass : interfaceList) {
             for (Method method : interfaceClass.getMethods()) {
                 methodModels.put(method, new ConsumerMethodModel(method));
             }
@@ -203,9 +200,9 @@ public class ConsumerModel {
      */
     public ConsumerMethodModel getMethodModel(String method, String[] 
argsType) {
         Optional<ConsumerMethodModel> consumerMethodModel = 
methodModels.entrySet().stream()
-                .filter(entry -> entry.getKey().getName().equals(method))
-                .map(Map.Entry::getValue).filter(methodModel -> 
Arrays.equals(argsType, methodModel.getParameterTypes()))
-                .findFirst();
+            .filter(entry -> entry.getKey().getName().equals(method))
+            .map(Map.Entry::getValue).filter(methodModel -> 
Arrays.equals(argsType, methodModel.getParameterTypes()))
+            .findFirst();
         return consumerMethodModel.orElse(null);
     }
 
diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ServiceRepository.java 
b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ServiceRepository.java
index 8442070..7567dcd 100644
--- 
a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ServiceRepository.java
+++ 
b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/ServiceRepository.java
@@ -30,6 +30,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
+import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
@@ -57,7 +58,7 @@ public class ServiceRepository extends LifecycleAdapter 
implements FrameworkExt
 
     public ServiceRepository() {
         Set<BuiltinServiceDetector> builtinServices
-                = 
ExtensionLoader.getExtensionLoader(BuiltinServiceDetector.class).getSupportedExtensionInstances();
+            = 
ExtensionLoader.getExtensionLoader(BuiltinServiceDetector.class).getSupportedExtensionInstances();
         if (CollectionUtils.isNotEmpty(builtinServices)) {
             for (BuiltinServiceDetector service : builtinServices) {
                 registerService(service.getService());
@@ -67,7 +68,7 @@ public class ServiceRepository extends LifecycleAdapter 
implements FrameworkExt
 
     public ServiceDescriptor registerService(Class<?> interfaceClazz) {
         return services.computeIfAbsent(interfaceClazz.getName(),
-                _k -> new ServiceDescriptor(interfaceClazz));
+            _k -> new ServiceDescriptor(interfaceClazz));
     }
 
     /**
@@ -103,9 +104,10 @@ public class ServiceRepository extends LifecycleAdapter 
implements FrameworkExt
                                  ServiceDescriptor serviceDescriptor,
                                  ReferenceConfigBase<?> rc,
                                  Object proxy,
-                                 ServiceMetadata serviceMetadata) {
+                                 ServiceMetadata serviceMetadata,
+                                 Map<String, AsyncMethodInfo> methodConfigs) {
         ConsumerModel consumerModel = new 
ConsumerModel(serviceMetadata.getServiceKey(), proxy, serviceDescriptor, rc,
-                serviceMetadata);
+            serviceMetadata, methodConfigs);
         consumers.putIfAbsent(serviceKey, consumerModel);
     }
 
@@ -123,7 +125,7 @@ public class ServiceRepository extends LifecycleAdapter 
implements FrameworkExt
                                  ServiceConfigBase<?> serviceConfig,
                                  ServiceMetadata serviceMetadata) {
         ProviderModel providerModel = new ProviderModel(serviceKey, 
serviceInstance, serviceModel, serviceConfig,
-                serviceMetadata);
+            serviceMetadata);
         providers.putIfAbsent(serviceKey, providerModel);
         providersWithoutGroup.putIfAbsent(keyWithoutGroup(serviceKey), 
providerModel);
     }
diff --git 
a/dubbo-compatible/src/test/java/org/apache/dubbo/config/MethodConfigTest.java 
b/dubbo-compatible/src/test/java/org/apache/dubbo/config/MethodConfigTest.java
index cf9c11c..dd33eaa 100644
--- 
a/dubbo-compatible/src/test/java/org/apache/dubbo/config/MethodConfigTest.java
+++ 
b/dubbo-compatible/src/test/java/org/apache/dubbo/config/MethodConfigTest.java
@@ -112,7 +112,7 @@ public class MethodConfigTest {
         methodConfig.setOninvokeMethod("setName");
         methodConfig.setOninvoke(new Person());
 
-        AsyncMethodInfo methodInfo = 
org.apache.dubbo.config.MethodConfig.convertMethodConfig2AsyncInfo(methodConfig);
+        AsyncMethodInfo methodInfo = 
methodConfig.convertMethodConfig2AsyncInfo();
 
         assertEquals(methodInfo.getOninvokeMethod(), 
Person.class.getMethod("setName", String.class));
     }
diff --git 
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
 
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
index 74ef3a5..9063c1c 100644
--- 
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
+++ 
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
@@ -41,10 +41,10 @@ import 
org.apache.dubbo.rpc.cluster.directory.StaticDirectory;
 import org.apache.dubbo.rpc.cluster.support.ClusterUtils;
 import org.apache.dubbo.rpc.cluster.support.registry.ZoneAwareCluster;
 import org.apache.dubbo.rpc.model.ApplicationModel;
-import org.apache.dubbo.rpc.model.AsyncMethodInfo;
-import org.apache.dubbo.rpc.model.ConsumerModel;
 import org.apache.dubbo.rpc.model.ServiceDescriptor;
 import org.apache.dubbo.rpc.model.ServiceRepository;
+import org.apache.dubbo.rpc.model.AsyncMethodInfo;
+import org.apache.dubbo.rpc.model.ConsumerModel;
 import org.apache.dubbo.rpc.protocol.injvm.InjvmProtocol;
 import org.apache.dubbo.rpc.service.GenericService;
 import org.apache.dubbo.rpc.support.ProtocolUtils;
@@ -107,12 +107,6 @@ public class ReferenceConfig<T> extends 
ReferenceConfigBase<T> {
     private static final Protocol REF_PROTOCOL = 
ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
 
     /**
-     * The {@link Cluster}'s implementation with adaptive functionality, and 
actually it will get a {@link Cluster}'s
-     * specific implementation who is wrapped with <b>MockClusterInvoker</b>
-     */
-    private static final Cluster CLUSTER = 
ExtensionLoader.getExtensionLoader(Cluster.class).getAdaptiveExtension();
-
-    /**
      * A {@link ProxyFactory} implementation that will generate a reference 
service's proxy,the JavassistProxyFactory is
      * its default implementation
      */
@@ -138,8 +132,6 @@ public class ReferenceConfig<T> extends 
ReferenceConfigBase<T> {
      */
     private transient volatile boolean destroyed;
 
-    private final ServiceRepository repository;
-
     private DubboBootstrap bootstrap;
 
     /**
@@ -151,12 +143,10 @@ public class ReferenceConfig<T> extends 
ReferenceConfigBase<T> {
 
     public ReferenceConfig() {
         super();
-        this.repository = ApplicationModel.getServiceRepository();
     }
 
     public ReferenceConfig(Reference reference) {
         super(reference);
-        this.repository = ApplicationModel.getServiceRepository();
     }
 
     /**
@@ -195,6 +185,7 @@ public class ReferenceConfig<T> extends 
ReferenceConfigBase<T> {
         this.services = services;
     }
 
+    @Override
     public synchronized T get() {
         if (destroyed) {
             throw new IllegalStateException("The invoker of ReferenceConfig(" 
+ url + ") has already destroyed!");
@@ -207,6 +198,7 @@ public class ReferenceConfig<T> extends 
ReferenceConfigBase<T> {
         return ref;
     }
 
+    @Override
     public synchronized void destroy() {
         if (ref == null) {
             return;
@@ -218,7 +210,7 @@ public class ReferenceConfig<T> extends 
ReferenceConfigBase<T> {
         try {
             invoker.destroy();
         } catch (Throwable t) {
-            logger.warn("Unexpected error occured when destroy invoker of 
ReferenceConfig(" + url + ").", t);
+            logger.warn("Unexpected error occurred when destroy invoker of 
ReferenceConfig(" + url + ").", t);
         }
         invoker = null;
         ref = null;
@@ -247,26 +239,74 @@ public class ReferenceConfig<T> extends 
ReferenceConfigBase<T> {
             this.refresh();
         }
 
-        //init serivceMetadata
+        //init serviceMetadata
         initServiceMetadata(consumer);
         serviceMetadata.setServiceType(getServiceInterfaceClass());
         // TODO, uncomment this line once service key is unified
         serviceMetadata.setServiceKey(URL.buildKey(interfaceName, group, 
version));
 
+        Map<String, String> referenceParameters = appendConfig();
+
+
         ServiceRepository repository = ApplicationModel.getServiceRepository();
         ServiceDescriptor serviceDescriptor = 
repository.registerService(interfaceClass);
         repository.registerConsumer(
-                serviceMetadata.getServiceKey(),
-                serviceDescriptor,
-                this,
-                null,
-                serviceMetadata);
+            serviceMetadata.getServiceKey(),
+            serviceDescriptor,
+            this,
+            null,
+            serviceMetadata,
+            createAsyncMethodInfo());
+
+        serviceMetadata.getAttachments().putAll(referenceParameters);
+
+        ref = createProxy(referenceParameters);
+
+        serviceMetadata.setTarget(ref);
+        serviceMetadata.addAttribute(PROXY_CLASS_REF, ref);
+
+        ConsumerModel consumerModel = 
repository.lookupReferredService(serviceMetadata.getServiceKey());
+        consumerModel.setProxyObject(ref);
+        consumerModel.initMethodModels();
 
+        initialized = true;
+
+        checkInvokerAvailable();
+    }
 
-        Map<String, String> map = new HashMap<String, String>();
+    /**
+     * convert and aggregate async method info
+     *
+     * @return Map<String, AsyncMethodInfo>
+     */
+    private Map<String, AsyncMethodInfo> createAsyncMethodInfo() {
+        Map<String, AsyncMethodInfo> attributes = null;
+        if (CollectionUtils.isNotEmpty(getMethods())) {
+            attributes = new HashMap<>(16);
+            for (MethodConfig methodConfig : getMethods()) {
+                AsyncMethodInfo asyncMethodInfo = 
methodConfig.convertMethodConfig2AsyncInfo();
+                if (asyncMethodInfo != null) {
+                    attributes.put(methodConfig.getName(), asyncMethodInfo);
+                }
+            }
+        }
+
+        return attributes;
+    }
+
+    /**
+     * Append all configuration required for service reference.
+     *
+     * @return reference parameters
+     */
+    private Map<String, String> appendConfig() {
+        Map<String, String> map = new HashMap<>(16);
+
+        map.put(INTERFACE_KEY, interfaceName);
         map.put(SIDE_KEY, CONSUMER_SIDE);
 
         ReferenceConfigBase.appendRuntimeParameters(map);
+
         if (!ProtocolUtils.isGeneric(generic)) {
             String revision = Version.getVersion(interfaceClass, version);
             if (revision != null && revision.length() > 0) {
@@ -278,24 +318,32 @@ public class ReferenceConfig<T> extends 
ReferenceConfigBase<T> {
                 logger.warn("No method found in service interface " + 
interfaceClass.getName());
                 map.put(METHODS_KEY, ANY_VALUE);
             } else {
-                map.put(METHODS_KEY, StringUtils.join(new 
HashSet<String>(Arrays.asList(methods)), COMMA_SEPARATOR));
+                map.put(METHODS_KEY, StringUtils.join(new 
HashSet<>(Arrays.asList(methods)), COMMA_SEPARATOR));
             }
         }
-        map.put(INTERFACE_KEY, interfaceName);
+
         AbstractConfig.appendParameters(map, getMetrics());
         AbstractConfig.appendParameters(map, getApplication());
         AbstractConfig.appendParameters(map, getModule());
-        // remove 'default.' prefix for configs from ConsumerConfig
-        // appendParameters(map, consumer, Constants.DEFAULT_KEY);
         AbstractConfig.appendParameters(map, consumer);
         AbstractConfig.appendParameters(map, this);
+
         MetadataReportConfig metadataReportConfig = getMetadataReportConfig();
         if (metadataReportConfig != null && metadataReportConfig.isValid()) {
             map.putIfAbsent(METADATA_KEY, REMOTE_METADATA_STORAGE_TYPE);
         }
-        Map<String, AsyncMethodInfo> attributes = null;
+
+        String hostToRegistry = 
ConfigUtils.getSystemProperty(DUBBO_IP_TO_REGISTRY);
+        if (StringUtils.isEmpty(hostToRegistry)) {
+            hostToRegistry = NetUtils.getLocalHost();
+        } else if (isInvalidLocalHost(hostToRegistry)) {
+            throw new IllegalArgumentException(
+                "Specified invalid registry ip from property:" + 
DUBBO_IP_TO_REGISTRY + ", value:" + hostToRegistry);
+        }
+
+        map.put(REGISTER_IP_KEY, hostToRegistry);
+
         if (CollectionUtils.isNotEmpty(getMethods())) {
-            attributes = new HashMap<>();
             for (MethodConfig methodConfig : getMethods()) {
                 AbstractConfig.appendParameters(map, methodConfig, 
methodConfig.getName());
                 String retryKey = methodConfig.getName() + ".retry";
@@ -305,143 +353,153 @@ public class ReferenceConfig<T> extends 
ReferenceConfigBase<T> {
                         map.put(methodConfig.getName() + ".retries", "0");
                     }
                 }
-                AsyncMethodInfo asyncMethodInfo = 
AbstractConfig.convertMethodConfig2AsyncInfo(methodConfig);
-                if (asyncMethodInfo != null) {
-//                    
consumerModel.getMethodModel(methodConfig.getName()).addAttribute(ASYNC_KEY, 
asyncMethodInfo);
-                    attributes.put(methodConfig.getName(), asyncMethodInfo);
-                }
             }
         }
 
-        String hostToRegistry = 
ConfigUtils.getSystemProperty(DUBBO_IP_TO_REGISTRY);
-        if (StringUtils.isEmpty(hostToRegistry)) {
-            hostToRegistry = NetUtils.getLocalHost();
-        } else if (isInvalidLocalHost(hostToRegistry)) {
-            throw new IllegalArgumentException(
-                    "Specified invalid registry ip from property:" + 
DUBBO_IP_TO_REGISTRY + ", value:" + hostToRegistry);
-        }
-        map.put(REGISTER_IP_KEY, hostToRegistry);
+        return map;
+    }
 
-        serviceMetadata.getAttachments().putAll(map);
+    @SuppressWarnings({"unchecked"})
+    private T createProxy(Map<String, String> referenceParameters) {
+        if (shouldJvmRefer(referenceParameters)) {
+            createInvokerForLocal(referenceParameters);
+        } else {
+            urls.clear();
+            if (url != null && url.length() > 0) {
+                // user specified URL, could be peer-to-peer address, or 
register center's address.
+                parseUrl(referenceParameters);
+            } else {
+                // if protocols not in jvm checkRegistry
+                if (!LOCAL_PROTOCOL.equalsIgnoreCase(getProtocol())) {
+                    aggregateUrlFromRegistry(referenceParameters);
+                }
+            }
+            createInvokerForRemote();
+        }
 
-        ref = createProxy(map);
+        if (logger.isInfoEnabled()) {
+            logger.info("Referred dubbo service " + interfaceClass.getName());
+        }
 
-        serviceMetadata.setTarget(ref);
-        serviceMetadata.addAttribute(PROXY_CLASS_REF, ref);
-        ConsumerModel consumerModel = 
repository.lookupReferredService(serviceMetadata.getServiceKey());
-        consumerModel.setProxyObject(ref);
-        consumerModel.init(attributes);
+        URL consumerUrl = new ServiceConfigURL(CONSUMER_PROTOCOL, 
referenceParameters.get(REGISTER_IP_KEY), 0,
+            referenceParameters.get(INTERFACE_KEY), referenceParameters);
+        MetadataUtils.publishServiceDefinition(consumerUrl);
 
-        initialized = true;
+        // create service proxy
+        return (T) PROXY_FACTORY.getProxy(invoker, 
ProtocolUtils.isGeneric(generic));
+    }
 
-        checkInvokerAvailable();
+    /**
+     * Make a local reference, create a local invoker.
+     *
+     * @param referenceParameters
+     */
+    private void createInvokerForLocal(Map<String, String> 
referenceParameters) {
+        URL url = new ServiceConfigURL(LOCAL_PROTOCOL, LOCALHOST_VALUE, 0, 
interfaceClass.getName()).addParameters(referenceParameters);
+        invoker = REF_PROTOCOL.refer(interfaceClass, url);
+        if (logger.isInfoEnabled()) {
+            logger.info("Using in jvm service " + interfaceClass.getName());
+        }
     }
 
-    @SuppressWarnings({"unchecked", "rawtypes", "deprecation"})
-    private T createProxy(Map<String, String> map) {
-        if (shouldJvmRefer(map)) {
-            URL url = new ServiceConfigURL(LOCAL_PROTOCOL, LOCALHOST_VALUE, 0, 
interfaceClass.getName()).addParameters(map);
-            invoker = REF_PROTOCOL.refer(interfaceClass, url);
-            if (logger.isInfoEnabled()) {
-                logger.info("Using injvm service " + interfaceClass.getName());
-            }
-        } else {
-            urls.clear();
-            if (url != null && url.length() > 0) { // user specified URL, 
could be peer-to-peer address, or register center's address.
-                String[] us = SEMICOLON_SPLIT_PATTERN.split(url);
-                if (us != null && us.length > 0) {
-                    for (String u : us) {
-                        URL url = URL.valueOf(u);
-                        if (StringUtils.isEmpty(url.getPath())) {
-                            url = url.setPath(interfaceName);
-                        }
-                        if (UrlUtils.isRegistry(url)) {
-                            urls.add(url.putAttribute(REFER_KEY, map));
-                        } else {
-                            URL peerURL = ClusterUtils.mergeUrl(url, map);
-                            peerURL = peerURL.putAttribute(PEER_KEY, true);
-                            urls.add(peerURL);
-                        }
-                    }
+    /**
+     * Parse the directly configured url.
+     */
+    private void parseUrl(Map<String, String> referenceParameters) {
+        String[] us = SEMICOLON_SPLIT_PATTERN.split(url);
+        if (us != null && us.length > 0) {
+            for (String u : us) {
+                URL url = URL.valueOf(u);
+                if (StringUtils.isEmpty(url.getPath())) {
+                    url = url.setPath(interfaceName);
                 }
-            } else { // assemble URL from register center's configuration
-                // if protocols not injvm checkRegistry
-                if (!LOCAL_PROTOCOL.equalsIgnoreCase(getProtocol())) {
-                    checkRegistry();
-                    List<URL> us = ConfigValidationUtils.loadRegistries(this, 
false);
-                    if (CollectionUtils.isNotEmpty(us)) {
-                        for (URL u : us) {
-                            URL monitorUrl = 
ConfigValidationUtils.loadMonitor(this, u);
-                            if (monitorUrl != null) {
-                                u = u.putAttribute(MONITOR_KEY, monitorUrl);
-                            }
-                            urls.add(u.putAttribute(REFER_KEY, map));
-                        }
-                    }
-                    if (urls.isEmpty()) {
-                        throw new IllegalStateException(
-                                "No such any registry to reference " + 
interfaceName + " on the consumer " + NetUtils.getLocalHost() +
-                                        " use dubbo version " + 
Version.getVersion() +
-                                        ", please config <dubbo:registry 
address=\"...\" /> to your spring config.");
-                    }
+                if (UrlUtils.isRegistry(url)) {
+                    urls.add(url.putAttribute(REFER_KEY, referenceParameters));
+                } else {
+                    URL peerUrl = ClusterUtils.mergeUrl(url, 
referenceParameters);
+                    peerUrl = peerUrl.putAttribute(PEER_KEY, true);
+                    urls.add(peerUrl);
                 }
             }
+        }
+    }
 
-            if (urls.size() == 1) {
-                invoker = REF_PROTOCOL.refer(interfaceClass, urls.get(0));
-            } else {
-                List<Invoker<?>> invokers = new ArrayList<Invoker<?>>();
-                URL registryURL = null;
-                for (URL url : urls) {
-                    // For multi-registry scenarios, it is not checked whether 
each referInvoker is available.
-                    // Because this invoker may become available later.
-                    invokers.add(REF_PROTOCOL.refer(interfaceClass, url));
-
-                    if (UrlUtils.isRegistry(url)) {
-                        registryURL = url; // use last registry url
-                    }
-                }
-
-                if (registryURL != null) { // registry url is available
-                    // for multi-subscription scenario, use 'zone-aware' 
policy by default
-                    String cluster = registryURL.getParameter(CLUSTER_KEY, 
ZoneAwareCluster.NAME);
-                    // The invoker wrap sequence would be: 
ZoneAwareClusterInvoker(StaticDirectory) -> 
FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker
-                    invoker = Cluster.getCluster(cluster, false).join(new 
StaticDirectory(registryURL, invokers));
-                } else { // not a registry url, must be direct invoke.
-                    String cluster = CollectionUtils.isNotEmpty(invokers)
-                            ?
-                            (invokers.get(0).getUrl() != null ? 
invokers.get(0).getUrl().getParameter(CLUSTER_KEY, ZoneAwareCluster.NAME) :
-                                    Cluster.DEFAULT)
-                            : Cluster.DEFAULT;
-                    invoker = Cluster.getCluster(cluster).join(new 
StaticDirectory(invokers));
+    /**
+     * Get URLs from the registry and aggregate them.
+     */
+    private void aggregateUrlFromRegistry(Map<String, String> 
referenceParameters) {
+        checkRegistry();
+        List<URL> us = ConfigValidationUtils.loadRegistries(this, false);
+        if (CollectionUtils.isNotEmpty(us)) {
+            for (URL u : us) {
+                URL monitorUrl = ConfigValidationUtils.loadMonitor(this, u);
+                if (monitorUrl != null) {
+                    u = u.putAttribute(MONITOR_KEY, monitorUrl);
                 }
+                urls.add(u.putAttribute(REFER_KEY, referenceParameters));
             }
         }
-
-        if (logger.isInfoEnabled()) {
-            logger.info("Referred dubbo service " + interfaceClass.getName());
+        if (urls.isEmpty()) {
+            throw new IllegalStateException(
+                "No such any registry to reference " + interfaceName + " on 
the consumer " + NetUtils.getLocalHost() +
+                    " use dubbo version " + Version.getVersion() +
+                    ", please config <dubbo:registry address=\"...\" /> to 
your spring config.");
         }
+    }
 
-        URL consumerURL = new ServiceConfigURL(CONSUMER_PROTOCOL, 
map.get(REGISTER_IP_KEY), 0, map.get(INTERFACE_KEY), map);
-        MetadataUtils.publishServiceDefinition(consumerURL);
 
-        // create service proxy
-        return (T) PROXY_FACTORY.getProxy(invoker, 
ProtocolUtils.isGeneric(generic));
+    /**
+     * Make a remote reference, create a remote reference invoker
+     */
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    private void createInvokerForRemote() {
+        if (urls.size() == 1) {
+            invoker = REF_PROTOCOL.refer(interfaceClass, urls.get(0));
+        } else {
+            List<Invoker<?>> invokers = new ArrayList<>();
+            URL registryUrl = null;
+            for (URL url : urls) {
+                // For multi-registry scenarios, it is not checked whether 
each referInvoker is available.
+                // Because this invoker may become available later.
+                invokers.add(REF_PROTOCOL.refer(interfaceClass, url));
+
+                if (UrlUtils.isRegistry(url)) {
+                    // use last registry url
+                    registryUrl = url;
+                }
+            }
+
+            if (registryUrl != null) {
+                // registry url is available
+                // for multi-subscription scenario, use 'zone-aware' policy by 
default
+                String cluster = registryUrl.getParameter(CLUSTER_KEY, 
ZoneAwareCluster.NAME);
+                // The invoker wrap sequence would be: 
ZoneAwareClusterInvoker(StaticDirectory) -> 
FailoverClusterInvoker(RegistryDirectory, routing happens here) -> Invoker
+                invoker = Cluster.getCluster(cluster, false).join(new 
StaticDirectory(registryUrl, invokers));
+            } else {
+                // not a registry url, must be direct invoke.
+                String cluster = CollectionUtils.isNotEmpty(invokers)
+                    ?
+                    (invokers.get(0).getUrl() != null ? 
invokers.get(0).getUrl().getParameter(CLUSTER_KEY, ZoneAwareCluster.NAME) :
+                        Cluster.DEFAULT)
+                    : Cluster.DEFAULT;
+                invoker = Cluster.getCluster(cluster).join(new 
StaticDirectory(invokers));
+            }
+        }
     }
 
     private void checkInvokerAvailable() throws IllegalStateException {
         if (shouldCheck() && !invoker.isAvailable()) {
             invoker.destroy();
             throw new IllegalStateException("Failed to check the status of the 
service "
-                    + interfaceName
-                    + ". No provider available for the service "
-                    + (group == null ? "" : group + "/")
-                    + interfaceName +
-                    (version == null ? "" : ":" + version)
-                    + " from the url "
-                    + invoker.getUrl()
-                    + " to the consumer "
-                    + NetUtils.getLocalHost() + " use dubbo version " + 
Version.getVersion());
+                + interfaceName
+                + ". No provider available for the service "
+                + (group == null ? "" : group + "/")
+                + interfaceName +
+                (version == null ? "" : ":" + version)
+                + " from the url "
+                + invoker.getUrl()
+                + " to the consumer "
+                + NetUtils.getLocalHost() + " use dubbo version " + 
Version.getVersion());
         }
     }
 
@@ -459,7 +517,7 @@ public class ReferenceConfig<T> extends 
ReferenceConfigBase<T> {
 
         // init some null configuration.
         List<ConfigInitializer> configInitializers = 
ExtensionLoader.getExtensionLoader(ConfigInitializer.class)
-                .getActivateExtension(URL.valueOf("configInitializer://"), 
(String[]) null);
+            .getActivateExtension(URL.valueOf("configInitializer://"), 
(String[]) null);
         configInitializers.forEach(e -> e.initReferConfig(this));
 
         if (getGeneric() == null && getConsumer() != null) {
@@ -470,7 +528,7 @@ public class ReferenceConfig<T> extends 
ReferenceConfigBase<T> {
         } else {
             try {
                 interfaceClass = Class.forName(interfaceName, true, 
Thread.currentThread()
-                        .getContextClassLoader());
+                    .getContextClassLoader());
             } catch (ClassNotFoundException e) {
                 throw new IllegalStateException(e.getMessage(), e);
             }
@@ -535,7 +593,7 @@ public class ReferenceConfig<T> extends 
ReferenceConfigBase<T> {
 
     private void postProcessConfig() {
         List<ConfigPostProcessor> configPostProcessors = 
ExtensionLoader.getExtensionLoader(ConfigPostProcessor.class)
-                .getActivateExtension(URL.valueOf("configPostProcessor://"), 
(String[]) null);
+            .getActivateExtension(URL.valueOf("configPostProcessor://"), 
(String[]) null);
         configPostProcessors.forEach(component -> 
component.postProcessReferConfig(this));
     }
 
diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
index 292ff51..e4ff7c4 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
@@ -138,7 +138,7 @@ public class RegistryProtocol implements Protocol {
     private final Map<String, ServiceConfigurationListener> 
serviceConfigurationListeners = new ConcurrentHashMap<>();
     private final ProviderConfigurationListener providerConfigurationListener 
= new ProviderConfigurationListener();
     //To solve the problem of RMI repeated exposure port conflicts, the 
services that have been exposed are no longer exposed.
-    //providerurl <--> exporter
+    //provider url <--> exporter
     private final ConcurrentMap<String, ExporterChangeableWrapper<?>> bounds = 
new ConcurrentHashMap<>();
     protected Protocol protocol;
     protected RegistryFactory registryFactory;
diff --git 
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocolTest.java
 
b/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocolTest.java
index 9e018b7..ca4d6b1 100644
--- 
a/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocolTest.java
+++ 
b/dubbo-rpc/dubbo-rpc-grpc/src/test/java/org/apache/dubbo/rpc/protocol/grpc/GrpcProtocolTest.java
@@ -24,6 +24,7 @@ import org.apache.dubbo.config.ReferenceConfigBase;
 import org.apache.dubbo.rpc.Protocol;
 import org.apache.dubbo.rpc.ProxyFactory;
 import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.rpc.model.AsyncMethodInfo;
 import org.apache.dubbo.rpc.model.ServiceDescriptor;
 import org.apache.dubbo.rpc.model.ServiceMetadata;
 import org.apache.dubbo.rpc.protocol.grpc.support.DubboGreeterGrpc;
@@ -33,6 +34,9 @@ import 
org.apache.dubbo.rpc.protocol.grpc.support.HelloRequest;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
+import java.util.HashMap;
+import java.util.Map;
+
 public class GrpcProtocolTest {
     private Protocol protocol = 
ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
     private ProxyFactory proxy = 
ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
@@ -61,13 +65,14 @@ public class GrpcProtocolTest {
         ServiceMetadata serviceMetadata = new ServiceMetadata();
         
serviceMetadata.setServiceKey(URL.buildKey(DubboGreeterGrpc.IGreeter.class.getName(),
 null, null));
 
+        Map<String, AsyncMethodInfo> methodConfigs = new HashMap<>();
         ApplicationModel.getServiceRepository().registerConsumer(
             url.getServiceKey(),
             serviceDescriptor,
             mockReferenceConfig,
             null,
-            serviceMetadata
-        );
+            serviceMetadata,
+            methodConfigs);
 
         protocol.export(proxy.getInvoker(serviceImpl, 
DubboGreeterGrpc.IGreeter.class, url));
         serviceImpl = 
proxy.getProxy(protocol.refer(DubboGreeterGrpc.IGreeter.class, url));

Reply via email to