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) { } catch (Exception e) {
log.error("Failed to delete ZK node {}", nodePath, e); log.error("Failed to delete ZK node {}", nodePath, e);
throw new RuntimeException(e);
} }
} }
private void destroyZkClient() { private void destroyZkClient() {
stopped = true; stopped = true;
try { unpublishCurrentServer();
unpublishCurrentServer();
} catch (Exception e) {
}
CloseableUtils.closeQuietly(cache); CloseableUtils.closeQuietly(cache);
CloseableUtils.closeQuietly(client); CloseableUtils.closeQuietly(client);
log.info("ZK client disconnected"); log.info("ZK client disconnected");
} }
@PreDestroy @PreDestroy
public void destroy() { private void destroy() {
destroyZkClient();
zkExecutorService.shutdownNow(); zkExecutorService.shutdownNow();
destroyZkClient();
log.info("Stopped discovery service"); log.info("Stopped discovery service");
} }