zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardoliveira <...@git.apache.org>
Subject [GitHub] zookeeper pull request #160: ZOOKEEPER-2680:Correct DataNode.getChildren() i...
Date Wed, 01 Feb 2017 18:59:46 GMT
Github user edwardoliveira commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/160#discussion_r98967876
  
    --- Diff: src/java/main/org/apache/zookeeper/server/DataTree.java ---
    @@ -1045,18 +1046,16 @@ private void getCounts(String path, Counts counts) {
             if (node == null) {
                 return;
             }
    -        Set<String> children = null;
    +        String[] children = null;
             int len = 0;
             synchronized (node) {
    -            children = node.getChildren();
    +            Set<String> childs = node.getChildren();
    +            children = childs.toArray(new String[childs.size()]);
    --- End diff --
    
    FYI (only): I *guess* some tests broke 'cause `toArray` copies the contents of `childs`
to `children` while `node.getChildren()` returns a internal reference (subject to underneath
change) to `children`. So, it would need to be something like `children = new HashSet<>(childs);`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message