[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-2680?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15847376#comment-15847376
 ] 

ASF GitHub Bot commented on ZOOKEEPER-2680:
-------------------------------------------

Github user eribeiro commented on the issue:

    https://github.com/apache/zookeeper/pull/160
  
    @arshadmohammad My two last questions (really!):
     
    * Is this change supposed to be applied to branch-3.4 and branch-3.5? 
    
    * I see that `DataNode.getChildren()` is called in half a dozen places with 
more or less the logic below:
    
    ```
                Set<String> childs = node.getChildren();
                if (childs != null) {
                    children = childs.toArray(new String[childs.size()]);
                }
                // children size is zero
    
               if (children != null) {
                   for (String child : children) {
                       // DO LOGIC
                   }
               }
    ```
    
    As `children` is zero length the for-each loop is not executed. I am fine 
with leaving this code as-is. Otherwise, we could remove the now useless `if 
(children != null)` calls. Wdyt?


> Correct DataNode.getChildren() inconsistent behaviour.
> ------------------------------------------------------
>
>                 Key: ZOOKEEPER-2680
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2680
>             Project: ZooKeeper
>          Issue Type: Bug
>          Components: server
>    Affects Versions: 3.4.9, 3.5.1
>            Reporter: Mohammad Arshad
>            Assignee: Mohammad Arshad
>             Fix For: 3.4.10, 3.5.3, 3.6.0
>
>         Attachments: ZOOKEEPER-2680-01.patch
>
>
> DataNode.getChildren() API returns null and empty set if there are no 
> children in it depending on when the API is called. DataNode.getChildren() 
> API behavior should be changed and it should always return empty set if the 
> node does not have any child
> *DataNode.getChildren() API Current Behavior:*
> # returns null initially
> When DataNode is created and no children are added yet, 
> DataNode.getChildren() returns null
> # returns empty set after all the children are deleted:
> created a Node
> add a child
> delete the child
> DataNode.getChildren() returns empty set.
> After fix DataNode.getChildren() should return empty set in all the above 
> cases.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to