You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by he...@apache.org on 2024/04/08 12:02:26 UTC

(shenyu) branch master updated: fix Invalid path error #5532 (#5533)

This is an automated email from the ASF dual-hosted git repository.

hefengen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new f21622bc04 fix Invalid path error #5532 (#5533)
f21622bc04 is described below

commit f21622bc04840b9edb25590fd4081c3bd36bda68
Author: aias00 <ro...@163.com>
AuthorDate: Mon Apr 8 20:02:19 2024 +0800

    fix Invalid path error #5532 (#5533)
    
    * fix Invalid path error #5532
    
    * fix Invalid path error #5532
---
 .../org/apache/shenyu/admin/listener/zookeeper/ZookeeperClient.java    | 3 ++-
 .../apache/shenyu/admin/listener/zookeeper/ZookeeperClientTest.java    | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperClient.java b/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperClient.java
index 00a54e11da..a9148c61a1 100644
--- a/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperClient.java
+++ b/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperClient.java
@@ -111,7 +111,8 @@ public class ZookeeperClient {
         try {
             return null != client.checkExists().forPath(key);
         } catch (Exception e) {
-            throw new ShenyuException(e);
+            LOGGER.error("check if key exist error", e);
+            return false;
         }
     }
 
diff --git a/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/test/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperClientTest.java b/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/test/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperClientTest.java
index c637459c8e..b6bc5496f4 100644
--- a/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/test/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperClientTest.java
+++ b/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/test/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperClientTest.java
@@ -50,6 +50,7 @@ import java.util.ArrayList;
 import java.util.List;
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -119,7 +120,7 @@ class ZookeeperClientTest {
 
     @Test
     void isExist() throws Exception {
-        assertThrows(ShenyuException.class, () -> client.isExist("/test"));
+        assertFalse(() -> client.isExist("/test"));
         ExistsBuilderImpl existsBuilder = mock(ExistsBuilderImpl.class);
         when(curatorFramework.checkExists()).thenReturn(existsBuilder);
         when(existsBuilder.forPath(anyString())).thenReturn(new Stat());