HBASE-15803 ZooKeeperWatcher's constructor can leak a ZooKeeper instance with throwing ZooKeeperConnectionException when canCreateBaseZNode is true

This commit is contained in:
tedyu 2016-06-06 18:35:15 -07:00
parent 15c03fd1c9
commit 7fd3532de6
1 changed files with 11 additions and 1 deletions

View File

@ -171,7 +171,17 @@ public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
this.recoverableZooKeeper = ZKUtil.connect(conf, quorum, pendingWatcher, identifier); this.recoverableZooKeeper = ZKUtil.connect(conf, quorum, pendingWatcher, identifier);
pendingWatcher.prepare(this); pendingWatcher.prepare(this);
if (canCreateBaseZNode) { 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;
}
} }
} }