test_class.file: dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/support/ClusterUtilsTest.java
test_class.identifier: ClusterUtilsTest
test_case.body: @Test
      public void testUseProviderParams() {
          // present in both local and remote, but uses remote value.
          URL localURL = URL.valueOf("dubbo://localhost:20880/DemoService?version=local&group=local&dubbo=local&release=local" +
                  "&methods=local&tag=local&timestamp=local");
          URL remoteURL = URL.valueOf("dubbo://localhost:20880/DemoService?version=remote&group=remote&dubbo=remote&release=remote" +
                  "&methods=remote&tag=remote&timestamp=remote");
          URL mergedUrl = ClusterUtils.mergeUrl(remoteURL, localURL.getParameters());
  
          Assertions.assertEquals(remoteURL.getParameter(VERSION_KEY), mergedUrl.getParameter(VERSION_KEY));
          Assertions.assertEquals(remoteURL.getParameter(GROUP_KEY), mergedUrl.getParameter(GROUP_KEY));
          Assertions.assertEquals(remoteURL.getParameter(DUBBO_VERSION_KEY), mergedUrl.getParameter(DUBBO_VERSION_KEY));
          Assertions.assertEquals(remoteURL.getParameter(RELEASE_KEY), mergedUrl.getParameter(RELEASE_KEY));
          Assertions.assertEquals(remoteURL.getParameter(METHODS_KEY), mergedUrl.getParameter(METHODS_KEY));
          Assertions.assertEquals(remoteURL.getParameter(TIMESTAMP_KEY), mergedUrl.getParameter(TIMESTAMP_KEY));
          Assertions.assertEquals(remoteURL.getParameter(TAG_KEY), mergedUrl.getParameter(TAG_KEY));
  
          // present in local url but not in remote url, parameters of remote url is empty
          localURL = URL.valueOf("dubbo://localhost:20880/DemoService?version=local&group=local&dubbo=local&release=local" +
                  "&methods=local&tag=local&timestamp=local");
          remoteURL = URL.valueOf("dubbo://localhost:20880/DemoService");
          mergedUrl = ClusterUtils.mergeUrl(remoteURL, localURL.getParameters());
  
          Assertions.assertEquals(mergedUrl.getParameter(VERSION_KEY),localURL.getParameter(VERSION_KEY));
          Assertions.assertEquals(mergedUrl.getParameter(GROUP_KEY),localURL.getParameter(GROUP_KEY));
          Assertions.assertNull(mergedUrl.getParameter(DUBBO_VERSION_KEY));
          Assertions.assertNull(mergedUrl.getParameter(RELEASE_KEY));
          Assertions.assertNull(mergedUrl.getParameter(METHODS_KEY));
          Assertions.assertNull(mergedUrl.getParameter(TIMESTAMP_KEY));
          Assertions.assertNull(mergedUrl.getParameter(TAG_KEY));
  
          // present in local url but not in remote url
          localURL = URL.valueOf("dubbo://localhost:20880/DemoService?version=local&group=local&dubbo=local&release=local" +
                  "&methods=local&tag=local&timestamp=local");
          remoteURL = URL.valueOf("dubbo://localhost:20880/DemoService?key=value");
          mergedUrl = ClusterUtils.mergeUrl(remoteURL, localURL.getParameters());
  
          Assertions.assertEquals(mergedUrl.getParameter(VERSION_KEY),localURL.getParameter(VERSION_KEY));
          Assertions.assertEquals(mergedUrl.getParameter(GROUP_KEY),localURL.getParameter(GROUP_KEY));
          Assertions.assertNull(mergedUrl.getParameter(DUBBO_VERSION_KEY));
          Assertions.assertNull(mergedUrl.getParameter(RELEASE_KEY));
          Assertions.assertNull(mergedUrl.getParameter(METHODS_KEY));
          Assertions.assertNull(mergedUrl.getParameter(TIMESTAMP_KEY));
          Assertions.assertNull(mergedUrl.getParameter(TAG_KEY));
  
          // present in both local and remote, uses local url params
          localURL = URL.valueOf("dubbo://localhost:20880/DemoService?loadbalance=local&timeout=1000&cluster=local");
          remoteURL = URL.valueOf("dubbo://localhost:20880/DemoService?loadbalance=remote&timeout=2000&cluster=remote");
          mergedUrl = ClusterUtils.mergeUrl(remoteURL, localURL.getParameters());
  
          Assertions.assertEquals(localURL.getParameter(CLUSTER_KEY), mergedUrl.getParameter(CLUSTER_KEY));
          Assertions.assertEquals(localURL.getParameter(TIMEOUT_KEY), mergedUrl.getParameter(TIMEOUT_KEY));
          Assertions.assertEquals(localURL.getParameter(LOADBALANCE_KEY), mergedUrl.getParameter(LOADBALANCE_KEY));
      }
test_case.class_method_signature: ClusterUtilsTest.testUseProviderParams()
test_case.full_signature: @Test public void testUseProviderParams()
test_case.identifier: testUseProviderParams
test_case.invocations: valueOf valueOf mergeUrl getParameters assertEquals getParameter getParameter assertEquals getParameter getParameter assertEquals getParameter getParameter assertEquals getParameter getParameter assertEquals getParameter getParameter assertEquals getParameter getParameter assertEquals getParameter getParameter valueOf valueOf mergeUrl getParameters assertEquals getParameter getParameter assertEquals getParameter getParameter assertNull getParameter assertNull getParameter assertNull getParameter assertNull getParameter assertNull getParameter valueOf valueOf mergeUrl getParameters assertEquals getParameter getParameter assertEquals getParameter getParameter assertNull getParameter assertNull getParameter assertNull getParameter assertNull getParameter assertNull getParameter valueOf valueOf mergeUrl getParameters assertEquals getParameter getParameter assertEquals getParameter getParameter assertEquals getParameter getParameter
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testUseProviderParams()
focal_class.file: dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/support/ClusterUtils.java
focal_class.identifier: ClusterUtils
focal_class.class_method_signature: ClusterUtils.ClusterUtils()
focal_class.full_signature: private  ClusterUtils()
focal_class.identifier: ClusterUtils
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.signature:  ClusterUtils()
focal_class.class_method_signature: ClusterUtils.mergeUrl(URL remoteUrl, Map<String, String> localMap)
focal_class.full_signature: public static URL mergeUrl(URL remoteUrl, Map<String, String> localMap)
focal_class.identifier: mergeUrl
focal_class.modifiers: public static
focal_class.parameters: (URL remoteUrl, Map<String, String> localMap)
focal_class.return: URL
focal_class.signature: URL mergeUrl(URL remoteUrl, Map<String, String> localMap)
focal_class.class_method_signature: ClusterUtils.mergeProviderUrl(URL remoteUrl, Map<String, String> localMap)
focal_class.full_signature: public static URL mergeProviderUrl(URL remoteUrl, Map<String, String> localMap)
focal_class.identifier: mergeProviderUrl
focal_class.modifiers: public static
focal_class.parameters: (URL remoteUrl, Map<String, String> localMap)
focal_class.return: URL
focal_class.signature: URL mergeProviderUrl(URL remoteUrl, Map<String, String> localMap)
focal_method.body: public static URL mergeUrl(URL remoteUrl, Map<String, String> localMap) {
          Map<String, String> map = new HashMap<String, String>();
          Map<String, String> remoteMap = remoteUrl.getParameters();
  
          if (remoteMap != null && remoteMap.size() > 0) {
              map.putAll(remoteMap);
  
              // Remove configurations from provider, some items should be affected by provider.
              map.remove(THREAD_NAME_KEY);
              map.remove(DEFAULT_KEY_PREFIX + THREAD_NAME_KEY);
  
              map.remove(THREADPOOL_KEY);
              map.remove(DEFAULT_KEY_PREFIX + THREADPOOL_KEY);
  
              map.remove(CORE_THREADS_KEY);
              map.remove(DEFAULT_KEY_PREFIX + CORE_THREADS_KEY);
  
              map.remove(THREADS_KEY);
              map.remove(DEFAULT_KEY_PREFIX + THREADS_KEY);
  
              map.remove(QUEUES_KEY);
              map.remove(DEFAULT_KEY_PREFIX + QUEUES_KEY);
  
              map.remove(ALIVE_KEY);
              map.remove(DEFAULT_KEY_PREFIX + ALIVE_KEY);
  
              map.remove(Constants.TRANSPORTER_KEY);
              map.remove(DEFAULT_KEY_PREFIX + Constants.TRANSPORTER_KEY);
          }
  
          if (localMap != null && localMap.size() > 0) {
              Map<String, String> copyOfLocalMap = new HashMap<>(localMap);
  
              if(map.containsKey(GROUP_KEY)){
                  copyOfLocalMap.remove(GROUP_KEY);
              }
              if(map.containsKey(VERSION_KEY)){
                  copyOfLocalMap.remove(VERSION_KEY);
              }
  
              copyOfLocalMap.remove(RELEASE_KEY);
              copyOfLocalMap.remove(DUBBO_VERSION_KEY);
              copyOfLocalMap.remove(METHODS_KEY);
              copyOfLocalMap.remove(TIMESTAMP_KEY);
              copyOfLocalMap.remove(TAG_KEY);
  
              map.putAll(copyOfLocalMap);
  
              map.put(REMOTE_APPLICATION_KEY, remoteMap.get(APPLICATION_KEY));
  
              // Combine filters and listeners on Provider and Consumer
              String remoteFilter = remoteMap.get(REFERENCE_FILTER_KEY);
              String localFilter = copyOfLocalMap.get(REFERENCE_FILTER_KEY);
              if (remoteFilter != null && remoteFilter.length() > 0
                      && localFilter != null && localFilter.length() > 0) {
                  map.put(REFERENCE_FILTER_KEY, remoteFilter + "," + localFilter);
              }
              String remoteListener = remoteMap.get(INVOKER_LISTENER_KEY);
              String localListener = copyOfLocalMap.get(INVOKER_LISTENER_KEY);
              if (remoteListener != null && remoteListener.length() > 0
                      && localListener != null && localListener.length() > 0) {
                  map.put(INVOKER_LISTENER_KEY, remoteListener + "," + localListener);
              }
          }
  
          return remoteUrl.clearParameters().addParameters(map);
      }
focal_method.class_method_signature: ClusterUtils.mergeUrl(URL remoteUrl, Map<String, String> localMap)
focal_method.full_signature: public static URL mergeUrl(URL remoteUrl, Map<String, String> localMap)
focal_method.identifier: mergeUrl
focal_method.invocations: getParameters size putAll remove remove remove remove remove remove remove remove remove remove remove remove remove remove size containsKey remove containsKey remove remove remove remove remove remove putAll put get get get length length put get get length length put addParameters clearParameters
focal_method.modifiers: public static
focal_method.parameters: (URL remoteUrl, Map<String, String> localMap)
focal_method.return: URL
focal_method.signature: URL mergeUrl(URL remoteUrl, Map<String, String> localMap)