Merge pull request #6 from qixiaobo/fix-group-for-register master
authormin <z82507200@gmail.com>
Thu, 1 Aug 2019 09:04:45 +0000 (17:04 +0800)
committerGitHub <noreply@github.com>
Thu, 1 Aug 2019 09:04:45 +0000 (17:04 +0800)
dubbo group not set for reference

1  2 
src/main/java/org/apache/dubbo/proxy/service/GenericInvoke.java

index 2783361b7d7e2c48992dd2a60a0a17f8894f3870,8c600b0d6a4036ad7a69e9e351c1cd83623e22e9..eccdcd885f23708115f97cecf275d61a19796d0f
@@@ -24,15 -24,16 +24,16 @@@ public class GenericInvoke 
          GenericInvoke.registry = registry;
      }
  
 -    public static void init() {
 +    private static void init() {
          RegistryConfig registryConfig = new RegistryConfig();
          registryConfig.setAddress(registry.getUrl().getProtocol() + "://" + registry.getUrl().getAddress());
+         registryConfig.setGroup(registry.getUrl().getParameter(org.apache.dubbo.common.constants.CommonConstants.GROUP_KEY));
          applicationConfig = new ApplicationConfig();
          applicationConfig.setName("dubbo-proxy");
          applicationConfig.setRegistry(registryConfig);
      }
  
 -    private static ConcurrentHashMap<String, ReferenceConfig> cachedConfig = new ConcurrentHashMap<>();
 +    private static ConcurrentHashMap<String, ReferenceConfig<GenericService>> cachedConfig = new ConcurrentHashMap<>();
      private static Logger logger = LoggerFactory.getLogger(GenericInvoke.class);
  
      public static Object genericCall(String interfaceName, String group,
          if (init.compareAndSet(false, true)) {
              init();
          }
 -        ReferenceConfig<GenericService> reference = null;
 +        ReferenceConfig<GenericService> reference;
          reference = addNewReference(interfaceName, group, version);
  
          try {
              GenericService svc = reference.get();
 -            logger.info("hsf generic invoke, service is {}, method is {} , paramTypes is {} , paramObjs is {} , svc is {}.", interfaceName
 +            logger.info("dubbo generic invoke, service is {}, method is {} , paramTypes is {} , paramObjs is {} , svc" +
 +                            " is {}.", interfaceName
                      , methodName,paramTypes,paramObjs,svc);
 -            Object result = svc.$invoke(methodName, paramTypes, paramObjs);
 -            return result;
 +            return svc.$invoke(methodName, paramTypes, paramObjs);
          } catch (Exception e) {
              logger.error("Generic invoke failed",e);
              if (e instanceof RpcException) {
@@@ -71,9 -72,9 +72,9 @@@
          }
      }
  
 -    private static ReferenceConfig addNewReference(String interfaceName,
 -                                                     String group, String version) {
 -        ReferenceConfig reference;
 +    private static ReferenceConfig<GenericService> addNewReference(String interfaceName,
 +                                                                   String group, String version) {
 +        ReferenceConfig<GenericService> reference;
          String cachedKey = interfaceName + group + version;
          reference = cachedConfig.get(cachedKey);
          if (reference == null) {
@@@ -89,8 -90,8 +90,8 @@@
          return reference;
      }
  
 -    private static ReferenceConfig initReference(String interfaceName, String group,
 -                                                String version) {
 +    private static ReferenceConfig<GenericService> initReference(String interfaceName, String group,
 +                                                                 String version) {
          ReferenceConfig<GenericService> reference = new ReferenceConfig<>();
          reference.setGeneric(true);
          reference.setApplication(applicationConfig);