Improve ZkDiscoveryService shutdown

This commit is contained in:
ViacheslavKlimov 2025-02-27 15:58:26 +02:00
parent aa0179303c
commit 16169dc728

View File

@ -251,25 +251,21 @@ public class ZkDiscoveryService implements DiscoveryService, PathChildrenCacheLi
}
} catch (Exception e) {
log.error("Failed to delete ZK node {}", nodePath, e);
throw new RuntimeException(e);
}
}
private void destroyZkClient() {
stopped = true;
try {
unpublishCurrentServer();
} catch (Exception e) {
}
CloseableUtils.closeQuietly(cache);
CloseableUtils.closeQuietly(client);
log.info("ZK client disconnected");
}
@PreDestroy
public void destroy() {
destroyZkClient();
private void destroy() {
zkExecutorService.shutdownNow();
destroyZkClient();
log.info("Stopped discovery service");
}