public URL mergeUrl(URL remoteUrl, Map<String, String> localMap) {

        String ump = localMap.get(URL_MERGE_PROCESSOR_KEY);
        ProviderURLMergeProcessor providerUrlMergeProcessor;

        if (StringUtils.isNotEmpty(ump)) {
            providerUrlMergeProcessor = applicationModel
                    .getExtensionLoader(ProviderURLMergeProcessor.class)
                    .getExtension(ump);
        } else {
            providerUrlMergeProcessor = applicationModel
                    .getExtensionLoader(ProviderURLMergeProcessor.class)
                    .getExtension("default");
        }

        return providerUrlMergeProcessor.mergeUrl(remoteUrl, localMap);
    }
@Test
    void testMergeUrl() {
        URL providerURL = URL.valueOf("dubbo://localhost:55555");
        providerURL = providerURL.setPath("path").setUsername("username").setPassword("password");

        providerURL = URLBuilder.from(providerURL)
                .addParameter(GROUP_KEY, "dubbo")
                .addParameter(VERSION_KEY, "1.2.3")
                .addParameter(DUBBO_VERSION_KEY, "2.3.7")
                .addParameter(THREADPOOL_KEY, "fixed")
                .addParameter(THREADS_KEY, Integer.MAX_VALUE)
                .addParameter(THREAD_NAME_KEY, "test")
                .addParameter(CORE_THREADS_KEY, Integer.MAX_VALUE)
                .addParameter(QUEUES_KEY, Integer.MAX_VALUE)
                .addParameter(ALIVE_KEY, Integer.MAX_VALUE)
                .addParameter(DEFAULT_KEY_PREFIX + THREADS_KEY, Integer.MAX_VALUE)
                .addParameter(DEFAULT_KEY_PREFIX + THREADPOOL_KEY, "fixed")
                .addParameter(DEFAULT_KEY_PREFIX + CORE_THREADS_KEY, Integer.MAX_VALUE)
                .addParameter(DEFAULT_KEY_PREFIX + QUEUES_KEY, Integer.MAX_VALUE)
                .addParameter(DEFAULT_KEY_PREFIX + ALIVE_KEY, Integer.MAX_VALUE)
                .addParameter(DEFAULT_KEY_PREFIX + THREAD_NAME_KEY, "test")
                .addParameter(APPLICATION_KEY, "provider")
                .addParameter(REFERENCE_FILTER_KEY, "filter1,filter2")
                .addParameter(TAG_KEY, "TTT")
                .build();

        // Verify default ProviderURLMergeProcessor
        URL consumerURL = new URLBuilder(DUBBO_PROTOCOL, "localhost", 55555)
                .addParameter(PID_KEY, "1234")
                .addParameter(THREADPOOL_KEY, "foo")
                .addParameter(APPLICATION_KEY, "consumer")
                .addParameter(REFERENCE_FILTER_KEY, "filter3")
                .addParameter(TAG_KEY, "UUU")
                .build();

        URL url = clusterUtils.mergeUrl(providerURL, consumerURL.getParameters());

        Assertions.assertFalse(url.hasParameter(THREADS_KEY));
        Assertions.assertFalse(url.hasParameter(DEFAULT_KEY_PREFIX + THREADS_KEY));

        Assertions.assertFalse(url.hasParameter(DEFAULT_KEY_PREFIX + THREADPOOL_KEY));

        Assertions.assertFalse(url.hasParameter(CORE_THREADS_KEY));
        Assertions.assertFalse(url.hasParameter(DEFAULT_KEY_PREFIX + CORE_THREADS_KEY));

        Assertions.assertFalse(url.hasParameter(QUEUES_KEY));
        Assertions.assertFalse(url.hasParameter(DEFAULT_KEY_PREFIX + QUEUES_KEY));

        Assertions.assertFalse(url.hasParameter(ALIVE_KEY));
        Assertions.assertFalse(url.hasParameter(DEFAULT_KEY_PREFIX + ALIVE_KEY));

        Assertions.assertFalse(url.hasParameter(THREAD_NAME_KEY));
        Assertions.assertFalse(url.hasParameter(DEFAULT_KEY_PREFIX + THREAD_NAME_KEY));

        Assertions.assertEquals("path", url.getPath());
        Assertions.assertEquals("username", url.getUsername());
        Assertions.assertEquals("password", url.getPassword());
        Assertions.assertEquals("1234", url.getParameter(PID_KEY));
        Assertions.assertEquals("foo", url.getParameter(THREADPOOL_KEY));
        Assertions.assertEquals("consumer", url.getApplication());
        Assertions.assertEquals("provider", url.getRemoteApplication());
        Assertions.assertEquals("filter1,filter2,filter3", url.getParameter(REFERENCE_FILTER_KEY));

        Assertions.assertEquals("TTT", url.getParameter(TAG_KEY));

        // Verify custom ProviderURLMergeProcessor
        URL consumerUrlForTag = new URLBuilder(DUBBO_PROTOCOL, "localhost", 55555)
                .addParameter(PID_KEY, "1234")
                .addParameter(THREADPOOL_KEY, "foo")
                .addParameter(APPLICATION_KEY, "consumer")
                .addParameter(REFERENCE_FILTER_KEY, "filter3")
                .addParameter(TAG_KEY, "UUU")
                .addParameter(URL_MERGE_PROCESSOR_KEY, "tag")
                .build();

        URL urlForTag = clusterUtils.mergeUrl(providerURL, consumerUrlForTag.getParameters());
        Assertions.assertEquals("UUU", urlForTag.getParameter(TAG_KEY));
    }