This is an automated email from the ASF dual-hosted git repository.
zrlw pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.3 by this push:
new b869c2cf84 Fixed hanging test cases when failed to download ZK image
that due to timeout or other problems (#15693)
b869c2cf84 is described below
commit b869c2cf84fa03e690262dbd99aa4854ccb8cf99
Author: zrlw <[email protected]>
AuthorDate: Thu Sep 18 14:00:37 2025 +0800
Fixed hanging test cases when failed to download ZK image that due to
timeout or other problems (#15693)
* Close CuratorFramework before throwing IllegalStateException to avoid
re-connecting ZK infinitely
* Check whether WatchDog is used or not to avoid hanging at destroyProcess
---
.../remoting/zookeeper/curator5/Curator5ZookeeperClient.java | 2 ++
.../check/registrycenter/context/ZookeeperWindowsContext.java | 11 ++++++++++-
.../registrycenter/processor/ResetZookeeperProcessor.java | 2 ++
3 files changed, 14 insertions(+), 1 deletion(-)
diff --git
a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClient.java
b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClient.java
index 63b714aa34..4fd59ecb02 100644
---
a/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClient.java
+++
b/dubbo-remoting/dubbo-remoting-zookeeper-curator5/src/main/java/org/apache/dubbo/remoting/zookeeper/curator5/Curator5ZookeeperClient.java
@@ -98,6 +98,8 @@ public class Curator5ZookeeperClient
boolean connected = client.blockUntilConnected(timeout,
TimeUnit.MILLISECONDS);
if (!connected) {
+ // close CuratorFramework to stop re-connection.
+ client.close();
IllegalStateException illegalStateException =
new IllegalStateException("zookeeper not connected,
the address is: " + url);
diff --git
a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/context/ZookeeperWindowsContext.java
b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/context/ZookeeperWindowsContext.java
index 7277ec1d33..80df283d93 100644
---
a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/context/ZookeeperWindowsContext.java
+++
b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/context/ZookeeperWindowsContext.java
@@ -49,6 +49,11 @@ public class ZookeeperWindowsContext extends
ZookeeperContext {
*/
private final ExecuteWatchdog WATCHDOG = new
ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT);
+ /**
+ * Set it to TRUE when using WatchDog.
+ */
+ private boolean usedWatchDog = false;
+
/**
* The map to store the pair of clientPort and PID.
*/
@@ -93,6 +98,7 @@ public class ZookeeperWindowsContext extends ZookeeperContext
{
* Returns the {@link ExecuteWatchdog}.
*/
public ExecuteWatchdog getWatchdog() {
+ usedWatchDog = true;
return WATCHDOG;
}
@@ -101,7 +107,10 @@ public class ZookeeperWindowsContext extends
ZookeeperContext {
*/
public void destroy() {
this.processIds.clear();
- this.WATCHDOG.destroyProcess();
+ // check WatchDog used flag to avoid hanging at destroyProcess when
WatchDog is not used.
+ if (usedWatchDog) {
+ this.WATCHDOG.destroyProcess();
+ }
try {
DEFAULT_EXECUTOR_SERVICE.shutdownNow();
} catch (SecurityException | NullPointerException ex) {
diff --git
a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/ResetZookeeperProcessor.java
b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/ResetZookeeperProcessor.java
index 012954e18f..9e1464c797 100644
---
a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/ResetZookeeperProcessor.java
+++
b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/ResetZookeeperProcessor.java
@@ -45,6 +45,8 @@ public class ResetZookeeperProcessor implements Processor {
client.start();
boolean connected = client.blockUntilConnected(1000,
TimeUnit.MILLISECONDS);
if (!connected) {
+ // close CuratorFramework to stop re-connection.
+ client.close();
throw new IllegalStateException("zookeeper not connected");
}
client.delete().deletingChildrenIfNeeded().forPath("/dubbo");