|
77 | 77 | import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY; |
78 | 78 | import static org.apache.dubbo.common.constants.CommonConstants.TIMESTAMP_KEY; |
79 | 79 | import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY; |
| 80 | +import static org.apache.dubbo.common.constants.CommonConstants.ON_CONNECT_KEY; |
| 81 | +import static org.apache.dubbo.common.constants.CommonConstants.ON_DISCONNECT_KEY; |
80 | 82 | import static org.apache.dubbo.common.constants.FilterConstants.VALIDATION_KEY; |
81 | 83 | import static org.apache.dubbo.common.constants.QosConstants.ACCEPT_FOREIGN_IP; |
82 | 84 | import static org.apache.dubbo.common.constants.QosConstants.QOS_ENABLE; |
@@ -370,29 +372,41 @@ protected URL getRegistryUrl(URL url) { |
370 | 372 | * @return url to registry. |
371 | 373 | */ |
372 | 374 | private URL getUrlToRegistry(final URL providerUrl, final URL registryUrl) { |
| 375 | + |
| 376 | + URL registeredProviderUrl = removeUselessParameters(providerUrl); |
| 377 | + |
373 | 378 | //The address you see at the registry |
374 | 379 | if (!registryUrl.getParameter(SIMPLIFIED_KEY, false)) { |
375 | | - return providerUrl.removeParameters(getHiddenKeys(providerUrl)).removeParameters( |
| 380 | + return registeredProviderUrl.removeParameters(getHiddenKeys(registeredProviderUrl)).removeParameters( |
376 | 381 | MONITOR_KEY, BIND_IP_KEY, BIND_PORT_KEY, QOS_ENABLE, QOS_HOST, QOS_PORT, ACCEPT_FOREIGN_IP, VALIDATION_KEY, |
377 | 382 | INTERFACES); |
378 | 383 | } else { |
379 | 384 | String extraKeys = registryUrl.getParameter(EXTRA_KEYS_KEY, ""); |
380 | 385 | // if path is not the same as interface name then we should keep INTERFACE_KEY, |
381 | 386 | // otherwise, the registry structure of zookeeper would be '/dubbo/path/providers', |
382 | 387 | // but what we expect is '/dubbo/interface/providers' |
383 | | - if (!providerUrl.getPath().equals(providerUrl.getParameter(INTERFACE_KEY))) { |
| 388 | + if (!registeredProviderUrl.getPath().equals(registeredProviderUrl.getParameter(INTERFACE_KEY))) { |
384 | 389 | if (StringUtils.isNotEmpty(extraKeys)) { |
385 | 390 | extraKeys += ","; |
386 | 391 | } |
387 | 392 | extraKeys += INTERFACE_KEY; |
388 | 393 | } |
389 | 394 | String[] paramsToRegistry = getParamsToRegistry(DEFAULT_REGISTER_PROVIDER_KEYS |
390 | 395 | , COMMA_SPLIT_PATTERN.split(extraKeys)); |
391 | | - return URL.valueOf(providerUrl, paramsToRegistry, providerUrl.getParameter(METHODS_KEY, (String[]) null)); |
| 396 | + return URL.valueOf(registeredProviderUrl, paramsToRegistry, registeredProviderUrl.getParameter(METHODS_KEY, (String[]) null)); |
392 | 397 | } |
393 | 398 |
|
394 | 399 | } |
395 | 400 |
|
| 401 | + /** |
| 402 | + * Remove information that does not require registration |
| 403 | + * @param providerUrl |
| 404 | + * @return |
| 405 | + */ |
| 406 | + private URL removeUselessParameters(URL providerUrl) { |
| 407 | + return providerUrl.removeParameters(ON_CONNECT_KEY, ON_DISCONNECT_KEY); |
| 408 | + } |
| 409 | + |
396 | 410 | private URL getSubscribedOverrideUrl(URL registeredProviderUrl) { |
397 | 411 | return registeredProviderUrl.setProtocol(PROVIDER_PROTOCOL) |
398 | 412 | .addParameters(CATEGORY_KEY, CONFIGURATORS_CATEGORY, CHECK_KEY, String.valueOf(false)); |
|
0 commit comments