Skip to content

Commit c57799c

Browse files
realJackSunWesleyOne
authored andcommitted
[ISSUE alibaba#3576] [Enhancement] Adding the destroy lifecycle method on NamingMaintainService (alibaba#3985)
1 parent d77392a commit c57799c

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

api/src/main/java/com/alibaba/nacos/api/naming/NamingMaintainService.java

+6
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,10 @@ void updateService(String serviceName, String groupName, float protectThreshold,
167167
*/
168168
void updateService(Service service, AbstractSelector selector) throws NacosException;
169169

170+
/**
171+
* Shutdown the resource service.
172+
*
173+
* @throws NacosException exception.
174+
*/
175+
void shutDown() throws NacosException;
170176
}

client/src/main/java/com/alibaba/nacos/client/naming/NacosNamingMaintainService.java

+4
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,8 @@ public void updateService(Service service, AbstractSelector selector) throws Nac
173173
serverProxy.updateService(service, selector);
174174
}
175175

176+
@Override
177+
public void shutDown() throws NacosException {
178+
serverProxy.shutdown();
179+
}
176180
}

test/src/test/java/com/alibaba/nacos/test/naming/NamingMaintainService_ITCase.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.alibaba.nacos.api.selector.NoneSelector;
3030
import com.alibaba.nacos.sys.utils.ApplicationUtils;
3131
import com.alibaba.nacos.test.BaseTest;
32+
import org.junit.After;
3233
import org.junit.Assert;
3334
import org.junit.Before;
3435
import org.junit.Test;
@@ -163,5 +164,10 @@ public void deleteService() throws NacosException {
163164

164165
Assert.assertTrue(namingMaintainService.deleteService(serviceName));
165166
}
166-
167+
168+
@After
169+
public void tearDown() throws NacosException {
170+
namingMaintainService.shutDown();
171+
namingService.shutDown();
172+
}
167173
}

0 commit comments

Comments
 (0)