From 97528396fdbe0836bff36d3fdda94dd288720eab Mon Sep 17 00:00:00 2001 From: fangjian0423 Date: Wed, 29 Jan 2020 22:08:50 +0800 Subject: [PATCH] extract dubbo spring cloud remove methods --- .../repository/DubboServiceMetadataRepository.java | 12 +++++------- .../dubbo/registry/AbstractSpringCloudRegistry.java | 3 +-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/spring-cloud-alibaba-dubbo/src/main/java/com/alibaba/cloud/dubbo/metadata/repository/DubboServiceMetadataRepository.java b/spring-cloud-alibaba-dubbo/src/main/java/com/alibaba/cloud/dubbo/metadata/repository/DubboServiceMetadataRepository.java index 7c80c0376..abd27b7f8 100644 --- a/spring-cloud-alibaba-dubbo/src/main/java/com/alibaba/cloud/dubbo/metadata/repository/DubboServiceMetadataRepository.java +++ b/spring-cloud-alibaba-dubbo/src/main/java/com/alibaba/cloud/dubbo/metadata/repository/DubboServiceMetadataRepository.java @@ -297,12 +297,15 @@ public class DubboServiceMetadataRepository } /** - * Remove the metadata of Dubbo Services if no there is no service instance. + * Remove the metadata and initialized service of Dubbo Services if no there is no + * service instance. * @param serviceName the service name */ - public void removeInitializedService(String serviceName) { + public void removeMetadataAndInitializedService(String serviceName) { synchronized (monitor) { initializedServices.remove(serviceName); + dubboRestServiceMetadataRepository.remove(serviceName); + subscribedDubboMetadataServiceURLs.remove(serviceName); } } @@ -644,11 +647,6 @@ public class DubboServiceMetadataRepository dubboMetadataConfigServiceProxy.initProxy(serviceName, version); } - public void removeMetadata(String serviceName) { - dubboRestServiceMetadataRepository.remove(serviceName); - subscribedDubboMetadataServiceURLs.remove(serviceName); - } - @Override public void setApplicationEventPublisher( ApplicationEventPublisher applicationEventPublisher) { diff --git a/spring-cloud-alibaba-dubbo/src/main/java/com/alibaba/cloud/dubbo/registry/AbstractSpringCloudRegistry.java b/spring-cloud-alibaba-dubbo/src/main/java/com/alibaba/cloud/dubbo/registry/AbstractSpringCloudRegistry.java index 6844f1425..2ba34d0a1 100644 --- a/spring-cloud-alibaba-dubbo/src/main/java/com/alibaba/cloud/dubbo/registry/AbstractSpringCloudRegistry.java +++ b/spring-cloud-alibaba-dubbo/src/main/java/com/alibaba/cloud/dubbo/registry/AbstractSpringCloudRegistry.java @@ -224,8 +224,7 @@ public abstract class AbstractSpringCloudRegistry extends FailbackRegistry { if (CollectionUtils.isEmpty(serviceInstances)) { dubboMetadataConfigServiceProxy.removeProxy(serviceName); - repository.removeInitializedService(serviceName); - repository.removeMetadata(serviceName); + repository.removeMetadataAndInitializedService(serviceName); dubboGenericServiceFactory.destroy(serviceName); if (logger.isWarnEnabled()) { logger.warn(