HBASE-5775 ZKUtil doesn't handle deleteRecurisively cleanly (Jesse Yates)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1325540 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eb5d2fe9d0
commit
fc9faf8585
|
@ -1004,7 +1004,9 @@ public class ZKUtil {
|
|||
|
||||
/**
|
||||
* Delete the specified node and all of it's children.
|
||||
*
|
||||
* <p>
|
||||
* If the node does not exist, just returns.
|
||||
* <p>
|
||||
* Sets no watches. Throws all exceptions besides dealing with deletion of
|
||||
* children.
|
||||
*/
|
||||
|
@ -1012,6 +1014,9 @@ public class ZKUtil {
|
|||
throws KeeperException {
|
||||
try {
|
||||
List<String> children = ZKUtil.listChildrenNoWatch(zkw, node);
|
||||
// the node is already deleted, so we just finish
|
||||
if (children == null) return;
|
||||
|
||||
if(!children.isEmpty()) {
|
||||
for(String child : children) {
|
||||
deleteNodeRecursively(zkw, joinZNode(node, child));
|
||||
|
|
|
@ -279,7 +279,12 @@ public class TestZooKeeper {
|
|||
assertNotNull(ZKUtil.getDataNoWatch(zkw, "/l1/l2/l3/l4", null));
|
||||
}
|
||||
ZKUtil.deleteNodeRecursively(zkw, "/l1/l2");
|
||||
// make sure it really is deleted
|
||||
assertNull(ZKUtil.getDataNoWatch(zkw, "/l1/l2/l3/l4", null));
|
||||
|
||||
// do the same delete again and make sure it doesn't crash
|
||||
ZKUtil.deleteNodeRecursively(zkw, "/l1/l2");
|
||||
|
||||
ZKUtil.deleteNode(zkw, "/l1");
|
||||
assertNull(ZKUtil.getDataNoWatch(zkw, "/l1/l2", null));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue