From 7527d76743d57744a855e304dfe81bebfc810874 Mon Sep 17 00:00:00 2001 From: JackSun-Developer Date: Wed, 14 Oct 2020 10:17:06 +0800 Subject: [PATCH] [ISSUE #3576] [Enhancement] Adding the destroy lifecycle method on NamingMaintainService (#3985) --- .../alibaba/nacos/api/naming/NamingMaintainService.java | 6 ++++++ .../nacos/client/naming/NacosNamingMaintainService.java | 4 ++++ .../nacos/test/naming/NamingMaintainService_ITCase.java | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/com/alibaba/nacos/api/naming/NamingMaintainService.java b/api/src/main/java/com/alibaba/nacos/api/naming/NamingMaintainService.java index 8dfc24a91..abcb5969b 100644 --- a/api/src/main/java/com/alibaba/nacos/api/naming/NamingMaintainService.java +++ b/api/src/main/java/com/alibaba/nacos/api/naming/NamingMaintainService.java @@ -167,4 +167,10 @@ public interface NamingMaintainService { */ void updateService(Service service, AbstractSelector selector) throws NacosException; + /** + * Shutdown the resource service. + * + * @throws NacosException exception. + */ + void shutDown() throws NacosException; } diff --git a/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingMaintainService.java b/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingMaintainService.java index f44e41b64..bb618a415 100644 --- a/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingMaintainService.java +++ b/client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingMaintainService.java @@ -173,4 +173,8 @@ public class NacosNamingMaintainService implements NamingMaintainService { serverProxy.updateService(service, selector); } + @Override + public void shutDown() throws NacosException { + serverProxy.shutdown(); + } } diff --git a/test/src/test/java/com/alibaba/nacos/test/naming/NamingMaintainService_ITCase.java b/test/src/test/java/com/alibaba/nacos/test/naming/NamingMaintainService_ITCase.java index 047d40c23..d59dd9e59 100644 --- a/test/src/test/java/com/alibaba/nacos/test/naming/NamingMaintainService_ITCase.java +++ b/test/src/test/java/com/alibaba/nacos/test/naming/NamingMaintainService_ITCase.java @@ -29,6 +29,7 @@ import com.alibaba.nacos.api.selector.ExpressionSelector; import com.alibaba.nacos.api.selector.NoneSelector; import com.alibaba.nacos.sys.utils.ApplicationUtils; import com.alibaba.nacos.test.BaseTest; +import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -163,5 +164,10 @@ public class NamingMaintainService_ITCase extends BaseTest { Assert.assertTrue(namingMaintainService.deleteService(serviceName)); } - + + @After + public void tearDown() throws NacosException { + namingMaintainService.shutDown(); + namingService.shutDown(); + } }