Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-11018

ZKUtil.getChildDataAndWatchForNewChildren() will not return null as indicated

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.96.1, 0.98.1
    • 0.99.0
    • Zookeeper
    • None
    • Reviewed

    Description

      While working on HBase acl, I found out that ZKUtil.getChildDataAndWatchForNewChildren() will not return null as indicated. Here is the code:

       /**
        ....
         * Returns null if the specified node does not exist.  Otherwise returns a
         * list of children of the specified node.  If the node exists but it has no
         * children, an empty list will be returned.
        ....
         */
        public static List<NodeAndData> getChildDataAndWatchForNewChildren(
            ZooKeeperWatcher zkw, String baseNode) throws KeeperException {
          List<String> nodes =
            ZKUtil.listChildrenAndWatchForNewChildren(zkw, baseNode);
          List<NodeAndData> newNodes = new ArrayList<NodeAndData>();
          if (nodes != null) {
            for (String node : nodes) {
              String nodePath = ZKUtil.joinZNode(baseNode, node);
              byte[] data = ZKUtil.getDataAndWatch(zkw, nodePath);
              newNodes.add(new NodeAndData(nodePath, data));
            }
          }
          return newNodes;
        }
      

      We return 'newNodes' which will never be null.

      This is a deprecated method. But it is still used in HBase code.
      For example: org.apache.hadoop.hbase.security.access.ZKPermissionWatcher.start()

        public void start() throws KeeperException {
          watcher.registerListener(this);
          if (ZKUtil.watchAndCheckExists(watcher, aclZNode)) {
            List<ZKUtil.NodeAndData> existing =
                ZKUtil.getChildDataAndWatchForNewChildren(watcher, aclZNode);
            if (existing != null) {
              refreshNodes(existing);
            }
          }
        }
      

      We test the 'null' return from the call which becomes the problem.

      Attachments

        1. HBASE-11018-trunk.patch
          1 kB
          Jerry He

        Activity

          People

            jinghe Jerry He
            jinghe Jerry He
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: