HBASE-15803 ZooKeeperWatcher's constructor can leak a ZooKeeper instance with throwing ZooKeeperConnectionException when canCreateBaseZNode is true
This commit is contained in:
parent
15c03fd1c9
commit
7fd3532de6
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue