This is an automated email from the ASF dual-hosted git repository. albumenj pushed a commit to branch 3.2 in repository https://gitbox.apache.org/repos/asf/dubbo.git
commit ed8e7715774ca052588b8c4ecf1c0ab0b3c673c1 Merge: b56687957e f9b27eddef Author: Albumen Kevin <[email protected]> AuthorDate: Sat Jan 14 14:37:16 2023 +0800 Merge branch 'apache-3.1' into apache-3.2 # Conflicts: # dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceDiscovery.java .../org/apache/dubbo/common/constants/CommonConstants.java | 2 ++ .../dubbo/common/utils/SerializeSecurityManager.java | 4 ++++ .../dubbo/registry/client/AbstractServiceDiscovery.java | 14 ++++++++++++-- .../apache/dubbo/registry/nacos/NacosServiceDiscovery.java | 2 +- .../registry/zookeeper/ZookeeperServiceDiscovery.java | 2 +- 5 files changed, 20 insertions(+), 4 deletions(-) diff --cc dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceDiscovery.java index 890b97be27,a589ec19ee..bb7122d960 --- a/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceDiscovery.java +++ b/dubbo-registry/dubbo-registry-nacos/src/main/java/org/apache/dubbo/registry/nacos/NacosServiceDiscovery.java @@@ -102,14 -105,28 +102,14 @@@ public class NacosServiceDiscovery exte @Override protected void doUpdate(ServiceInstance oldServiceInstance, ServiceInstance newServiceInstance) throws RuntimeException { - if (EMPTY_REVISION.equals(getExportedServicesRevision(newServiceInstance))) { - super.doUpdate(oldServiceInstance, newServiceInstance); - return; - } - - if (!Objects.equals(oldServiceInstance.getServiceName(), newServiceInstance.getServiceName()) || - !Objects.equals(oldServiceInstance.getAddress(), newServiceInstance.getAddress()) || - !Objects.equals(oldServiceInstance.getPort(), newServiceInstance.getPort())) { - // Ignore if host-ip changed. Should unregister first. - super.doUpdate(oldServiceInstance, newServiceInstance); - return; - } - - try { + // register first to ensure that consumer will not throw no provider exception + if (!EMPTY_REVISION.equals(getExportedServicesRevision(serviceInstance))) { - reportMetadata(serviceInstance.getServiceMetadata()); this.serviceInstance = newServiceInstance; + reportMetadata(newServiceInstance.getServiceMetadata()); - - // override without unregister this.doRegister(newServiceInstance); - } catch (Exception e) { - throw new RpcException(REGISTRY_EXCEPTION, "Failed register instance " + newServiceInstance.toString(), e); } + + this.doUnregister(oldServiceInstance); } @Override
