This is an automated email from the ASF dual-hosted git repository.
stoty pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new 1a833591295 HBASE-29313 RecoverableZooKeeper.getZooKeeper() returns
null for new object (#6988)
1a833591295 is described below
commit 1a8335912952e25b7cd4081e1b17a358844368e6
Author: Istvan Toth <[email protected]>
AuthorDate: Thu May 15 16:54:45 2025 +0200
HBASE-29313 RecoverableZooKeeper.getZooKeeper() returns null for new object
(#6988)
Signed-off-by: Duo Zhang <[email protected]>
---
.../hadoop/hbase/zookeeper/RecoverableZooKeeper.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git
a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java
b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java
index a70bed2839f..a590512dfcb 100644
---
a/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java
+++
b/hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/RecoverableZooKeeper.java
@@ -805,8 +805,20 @@ public class RecoverableZooKeeper {
return zk == null ? null : zk.getState();
}
+ /**
+ * Returns the wrapped ZooKeeper client. If the wrapped client hasn't been
created yet then tries
+ * create it first.
+ * @return the wrapped ZK client of null if the creation has failed.
+ */
public synchronized ZooKeeper getZooKeeper() {
- return zk;
+ // Callers expect an initialized ZooKeeper instance
+ // Pre HBASE-28529 the constructor used to call checkZk()
+ try {
+ return checkZk();
+ } catch (Exception x) {
+ LOG.warn("Failed to initialize Zookeeper object, returning null", x);
+ return null;
+ }
}
public synchronized byte[] getSessionPasswd() {