diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java index e6c8eb914c0..3b0c2b68f58 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java @@ -181,7 +181,17 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable { this.recoverableZooKeeper = ZKUtil.connect(conf, quorum, pendingWatcher, identifier); pendingWatcher.prepare(this); if (canCreateBaseZNode) { - createBaseZNodes(); + try { + createBaseZNodes(); + } catch (ZooKeeperConnectionException zce) { + try { + this.recoverableZooKeeper.close(); + } catch (InterruptedException ie) { + LOG.debug("Encountered InterruptedException when closing " + this.recoverableZooKeeper); + Thread.currentThread().interrupt(); + } + throw zce; + } } }