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

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


The following commit(s) were added to refs/heads/master by this push:
     new 790dfce  Unregister onconnect and ondisconnect information (#7482)
790dfce is described below

commit 790dfce51ab5263cbf42387dbe06c10d85888298
Author: huazhongming <[email protected]>
AuthorDate: Thu Apr 1 10:21:30 2021 +0800

    Unregister onconnect and ondisconnect information (#7482)
    
    * onconnect and ondisconnect should not be transmitted to Consumer side
    
    * fix import
---
 .../dubbo/common/constants/CommonConstants.java      |  9 +++++++++
 .../dubbo/registry/integration/RegistryProtocol.java | 20 +++++++++++++++++---
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
 
b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
index 9031eaf..002df3b 100644
--- 
a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
+++ 
b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/CommonConstants.java
@@ -381,4 +381,13 @@ public interface CommonConstants {
     String ENABLE_NATIVE_JAVA_GENERIC_SERIALIZE = 
"dubbo.security.serialize.generic.native-java-enable";
 
     String SERIALIZE_BLOCKED_LIST_FILE_PATH = "security/serialize.blockedlist";
+
+
+    /**
+     *  Interface configuration item
+     * @since 2.7.10
+     */
+    String ON_CONNECT_KEY = "onconnect";
+
+    String ON_DISCONNECT_KEY = "ondisconnect";
 }
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 37383eb..35ba7f6 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
@@ -77,6 +77,8 @@ import static 
org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.TIMESTAMP_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
+import static org.apache.dubbo.common.constants.CommonConstants.ON_CONNECT_KEY;
+import static 
org.apache.dubbo.common.constants.CommonConstants.ON_DISCONNECT_KEY;
 import static org.apache.dubbo.common.constants.FilterConstants.VALIDATION_KEY;
 import static org.apache.dubbo.common.constants.QosConstants.ACCEPT_FOREIGN_IP;
 import static org.apache.dubbo.common.constants.QosConstants.QOS_ENABLE;
@@ -370,9 +372,12 @@ public class RegistryProtocol implements Protocol {
      * @return url to registry.
      */
     private URL getUrlToRegistry(final URL providerUrl, final URL registryUrl) 
{
+
+        URL registeredProviderUrl = removeUselessParameters(providerUrl);
+
         //The address you see at the registry
         if (!registryUrl.getParameter(SIMPLIFIED_KEY, false)) {
-            return 
providerUrl.removeParameters(getHiddenKeys(providerUrl)).removeParameters(
+            return 
registeredProviderUrl.removeParameters(getHiddenKeys(registeredProviderUrl)).removeParameters(
                     MONITOR_KEY, BIND_IP_KEY, BIND_PORT_KEY, QOS_ENABLE, 
QOS_HOST, QOS_PORT, ACCEPT_FOREIGN_IP, VALIDATION_KEY,
                     INTERFACES);
         } else {
@@ -380,7 +385,7 @@ public class RegistryProtocol implements Protocol {
             // if path is not the same as interface name then we should keep 
INTERFACE_KEY,
             // otherwise, the registry structure of zookeeper would be 
'/dubbo/path/providers',
             // but what we expect is '/dubbo/interface/providers'
-            if 
(!providerUrl.getPath().equals(providerUrl.getParameter(INTERFACE_KEY))) {
+            if 
(!registeredProviderUrl.getPath().equals(registeredProviderUrl.getParameter(INTERFACE_KEY)))
 {
                 if (StringUtils.isNotEmpty(extraKeys)) {
                     extraKeys += ",";
                 }
@@ -388,11 +393,20 @@ public class RegistryProtocol implements Protocol {
             }
             String[] paramsToRegistry = 
getParamsToRegistry(DEFAULT_REGISTER_PROVIDER_KEYS
                     , COMMA_SPLIT_PATTERN.split(extraKeys));
-            return URL.valueOf(providerUrl, paramsToRegistry, 
providerUrl.getParameter(METHODS_KEY, (String[]) null));
+            return URL.valueOf(registeredProviderUrl, paramsToRegistry, 
registeredProviderUrl.getParameter(METHODS_KEY, (String[]) null));
         }
 
     }
 
+    /**
+     * Remove information that does not require registration
+     * @param providerUrl
+     * @return
+     */
+    private URL removeUselessParameters(URL providerUrl) {
+        return providerUrl.removeParameters(ON_CONNECT_KEY, ON_DISCONNECT_KEY);
+    }
+
     private URL getSubscribedOverrideUrl(URL registeredProviderUrl) {
         return registeredProviderUrl.setProtocol(PROVIDER_PROTOCOL)
                 .addParameters(CATEGORY_KEY, CONFIGURATORS_CATEGORY, 
CHECK_KEY, String.valueOf(false));

Reply via email to