You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by am...@apache.org on 2026/04/29 16:34:40 UTC
(aries-rsa) 02/03: ARIES-2200 Fix ZooKeeper concurrency issue that may close the wrong client
This is an automated email from the ASF dual-hosted git repository.
amichair pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
commit dd72c2818baeb17eb6205ba67090335759a200f5
Author: Amichai Rothman <am...@apache.org>
AuthorDate: Wed Apr 1 12:23:41 2026 +0300
ARIES-2200 Fix ZooKeeper concurrency issue that may close the wrong client
---
.../rsa/discovery/zookeeper/client/ClientManager.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ClientManager.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ClientManager.java
index 388e7633..90d839e4 100644
--- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ClientManager.java
+++ b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ClientManager.java
@@ -92,15 +92,15 @@ public class ClientManager implements Watcher {
if (reg != null) {
reg.unregister();
}
- runAsync(this::closeClient);
- }
-
- private void closeClient() {
- try {
- zkClient.close();
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
+ // keep current client reference to avoid race condition when re-starting a new one
+ ZooKeeper client = zkClient;
+ runAsync(() -> {
+ try {
+ client.close();
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ }
+ });
}
/* Callback for ZooKeeper */