hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1325540 - in /hbase/trunk/src: main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java test/java/org/apache/hadoop/hbase/TestZooKeeper.java
Date Thu, 12 Apr 2012 21:53:55 GMT
Author: larsh
Date: Thu Apr 12 21:53:54 2012
New Revision: 1325540

URL: http://svn.apache.org/viewvc?rev=1325540&view=rev
Log:
HBASE-5775 ZKUtil doesn't handle deleteRecurisively cleanly (Jesse Yates)

Modified:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java?rev=1325540&r1=1325539&r2=1325540&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java Thu Apr 12 21:53:54
2012
@@ -1004,14 +1004,19 @@ public class ZKUtil {
 
   /**
    * Delete the specified node and all of it's children.
-   *
-   * Sets no watches.  Throws all exceptions besides dealing with deletion of
+   * <p>
+   * If the node does not exist, just returns.
+   * <p>
+   * Sets no watches. Throws all exceptions besides dealing with deletion of
    * children.
    */
   public static void deleteNodeRecursively(ZooKeeperWatcher zkw, String node)
   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));

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java?rev=1325540&r1=1325539&r2=1325540&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java Thu Apr 12 21:53:54
2012
@@ -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));
   }



Mime
View raw message