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

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


The following commit(s) were added to refs/heads/3.1 by this push:
     new e86e6e3209 Fix zookeeper instance update (#11212)
e86e6e3209 is described below

commit e86e6e3209b6452f4b0d2a0f108a46ac6d19c2d5
Author: Albumen Kevin <[email protected]>
AuthorDate: Thu Dec 29 17:12:33 2022 +0800

    Fix zookeeper instance update (#11212)
---
 .../registry/zookeeper/ZookeeperServiceDiscovery.java     | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git 
a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscovery.java
 
b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscovery.java
index 8555cf142c..f0f2a6fc98 100644
--- 
a/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscovery.java
+++ 
b/dubbo-registry/dubbo-registry-zookeeper/src/main/java/org/apache/dubbo/registry/zookeeper/ZookeeperServiceDiscovery.java
@@ -42,6 +42,8 @@ import java.util.concurrent.CountDownLatch;
 
 import static 
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ZOOKEEPER_EXCEPTION;
 import static org.apache.dubbo.common.function.ThrowableFunction.execute;
+import static org.apache.dubbo.metadata.RevisionResolver.EMPTY_REVISION;
+import static 
org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.getExportedServicesRevision;
 import static 
org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkUtils.build;
 import static 
org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkUtils.buildCuratorFramework;
 import static 
org.apache.dubbo.registry.zookeeper.util.CuratorFrameworkUtils.buildServiceDiscovery;
@@ -106,6 +108,19 @@ public class ZookeeperServiceDiscovery extends 
AbstractServiceDiscovery {
         }
     }
 
+    @Override
+    protected void doUpdate(ServiceInstance serviceInstance) throws 
RuntimeException {
+        if 
(!EMPTY_REVISION.equals(getExportedServicesRevision(serviceInstance))) {
+            reportMetadata(serviceInstance.getServiceMetadata());
+        }
+
+        try {
+            serviceDiscovery.updateService(build(serviceInstance));
+        } catch (Exception e) {
+            throw new RpcException(REGISTRY_EXCEPTION, "Failed register 
instance " + serviceInstance.toString(), e);
+        }
+    }
+
     @Override
     public Set<String> getServices() {
         return doInServiceDiscovery(s -> new 
LinkedHashSet<>(s.queryForNames()));

Reply via email to