zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] (ZOOKEEPER-2680) Correct DataNode.getChildren() inconsistent behaviour.
Date Tue, 31 Jan 2017 16:35:55 GMT

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

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

Github user eribeiro commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/160#discussion_r98710030
  
    --- Diff: src/java/test/org/apache/zookeeper/server/DataNodeTest.java ---
    @@ -0,0 +1,54 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.zookeeper.server;
    +
    +import static org.junit.Assert.*;
    +
    +import java.util.Set;
    +
    +import org.junit.Test;
    +
    +public class DataNodeTest {
    +
    +    @Test
    +    public void testGetChildrenShouldReturnEmptySetWhenThereAreNoChidren() {
    +        // create DataNode and call getChildren
    +        DataNode dataNode = new DataNode();
    +        Set<String> children = dataNode.getChildren();
    +        assertNotNull(children);
    +        assertEquals(0, children.size());
    +
    +        // add child,remove child and then call getChildren
    +        String child = "child";
    +        dataNode.addChild(child);
    +        dataNode.removeChild(child);
    +        children = dataNode.getChildren();
    +        assertNotNull(children);
    +        assertEquals(0, children.size());
    +
    +        // Returned empty set must not be modifiable
    --- End diff --
    
    Ignore my previous comment. +1 about putting this in a separate method.


> 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)

Mime
View raw message