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

chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi-shaded.git


The following commit(s) were added to refs/heads/master by this push:
     new b20fd14  [KYUUBI #6496] Step 2/2: Port ZOOKEEPER-4377 to Kyuubi shaded 
ZooKeeper 3.4 and 3.6
b20fd14 is described below

commit b20fd148bd1dc19b2ef940baee7d8c451b513b24
Author: madlnu <[email protected]>
AuthorDate: Tue Jul 16 20:05:13 2024 +0800

    [KYUUBI #6496] Step 2/2: Port ZOOKEEPER-4377 to Kyuubi shaded ZooKeeper 3.4 
and 3.6
    
    ### _Why are the changes needed?_
    
    This is continuation of PR - #46 aims to resolve issue [Kyuubi 
6496](https://github.com/apache/kyuubi/issues/6496).
    In this PR, the 
[zookeeper-4377](https://github.com/apache/zookeeper/pull/1764) change has been 
backported
    
    ### _How was this patch tested?_
    
    This was built locally and tested in local using following steps:
    
    1. perform build/mvn clean package to generate 
kyuubi-relocated-zookeeper-parent/kyuubi-relocated-zookeeper-34/target/kyuubi-relocated-zookeeper-34-0.5.0-SNAPSHOT.jar
    2. download and install 
[apache-kyuubi-1.9.1-bin.tgz](https://dlcdn.apache.org/kyuubi/kyuubi-1.9.1/apache-kyuubi-1.9.1-bin.tgz)
    3. replace 
KYUUBI_HOME/jars/kyuubi-relocated-zookeeper-34-0.3.0-SNAPSHOT.jar with 
kyuubi-relocated-zookeeper-34-0.5.0-SNAPSHOT.jar
    4. perform bin/kyuubi-zk-cli -server xxxxx:2181 to connect a Zookeeper 
cluster
    
    Closes #47 from Madhukar525722/zoo-4377.
    
    84aca7c [madlnu] [KYUUBI #6496] Step 2/2: Port ZOOKEEPER-4377 to Kyuubi 
shaded ZooKeeper 3.4 and 3.6
    
    Authored-by: madlnu <[email protected]>
    Signed-off-by: Cheng Pan <[email protected]>
---
 .../src/main/java/org/apache/zookeeper/KeeperException.java  | 12 +++++++++---
 .../src/main/java/org/apache/zookeeper/KeeperException.java  | 12 +++++++++---
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git 
a/kyuubi-relocated-zookeeper-parent/kyuubi-relocated-zookeeper-34/src/main/java/org/apache/zookeeper/KeeperException.java
 
b/kyuubi-relocated-zookeeper-parent/kyuubi-relocated-zookeeper-34/src/main/java/org/apache/zookeeper/KeeperException.java
index 0e1106c..c53710e 100644
--- 
a/kyuubi-relocated-zookeeper-parent/kyuubi-relocated-zookeeper-34/src/main/java/org/apache/zookeeper/KeeperException.java
+++ 
b/kyuubi-relocated-zookeeper-parent/kyuubi-relocated-zookeeper-34/src/main/java/org/apache/zookeeper/KeeperException.java
@@ -118,7 +118,7 @@ public abstract class KeeperException extends Exception {
 
       case OK:
       default:
-        throw new IllegalArgumentException("Invalid exception code");
+        throw new IllegalArgumentException("Invalid exception code:" + 
code.code);
     }
   }
 
@@ -282,10 +282,16 @@ public abstract class KeeperException extends Exception {
      * Get the Code value for a particular integer error code
      *
      * @param code int error code
-     * @return Code value corresponding to specified int code, or null
+     * @return Code value corresponding to specified int code, if null throws
+     *     IllegalArgumentException
      */
     public static Code get(int code) {
-      return lookup.get(code);
+      Code codeVal = lookup.get(code);
+      if (codeVal == null) {
+        throw new IllegalArgumentException(
+            "The current client version cannot lookup this code:" + code);
+      }
+      return codeVal;
     }
   }
 
diff --git 
a/kyuubi-relocated-zookeeper-parent/kyuubi-relocated-zookeeper-36/src/main/java/org/apache/zookeeper/KeeperException.java
 
b/kyuubi-relocated-zookeeper-parent/kyuubi-relocated-zookeeper-36/src/main/java/org/apache/zookeeper/KeeperException.java
index d61be4a..67b56c0 100644
--- 
a/kyuubi-relocated-zookeeper-parent/kyuubi-relocated-zookeeper-36/src/main/java/org/apache/zookeeper/KeeperException.java
+++ 
b/kyuubi-relocated-zookeeper-parent/kyuubi-relocated-zookeeper-36/src/main/java/org/apache/zookeeper/KeeperException.java
@@ -136,7 +136,7 @@ public abstract class KeeperException extends Exception {
         return new RequestTimeoutException();
       case OK:
       default:
-        throw new IllegalArgumentException("Invalid exception code");
+        throw new IllegalArgumentException("Invalid exception code:" + 
code.code);
     }
   }
 
@@ -340,10 +340,16 @@ public abstract class KeeperException extends Exception {
      * Get the Code value for a particular integer error code
      *
      * @param code int error code
-     * @return Code value corresponding to specified int code, or null
+     * @return Code value corresponding to specified int code, if null throws
+     *     IllegalArgumentException
      */
     public static Code get(int code) {
-      return lookup.get(code);
+      Code codeVal = lookup.get(code);
+      if (codeVal == null) {
+        throw new IllegalArgumentException(
+            "The current client version cannot lookup this code:" + code);
+      }
+      return codeVal;
     }
   }
 

Reply via email to