You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by "richard.zhao (JIRA)" <ji...@apache.org> on 2015/09/29 09:23:05 UTC

[jira] [Created] (ZOOKEEPER-2286) Doc Issue

richard.zhao created ZOOKEEPER-2286:
---------------------------------------

             Summary: Doc Issue
                 Key: ZOOKEEPER-2286
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2286
             Project: ZooKeeper
          Issue Type: Improvement
          Components: documentation
    Affects Versions: 3.4.6
            Reporter: richard.zhao
            Priority: Minor


First, thanks for your detail documents. It's very helpful.

In this one "Programming with ZooKeeper - A basic tutorial"
(URL: https://zookeeper.apache.org/doc/trunk/zookeeperTutorial.html)

The demo code has a small issue.
---------------------------------------------------------------------------------
boolean enter() throws KeeperException, InterruptedException{
            zk.create(root + "/" + name, new byte[0], Ids.OPEN_ACL_UNSAFE,
                    CreateMode.EPHEMERAL_SEQUENTIAL);
            while (true) {
                synchronized (mutex) {
                    List<String> list = zk.getChildren(root, true);

                    if (list.size() < size) {
                        mutex.wait();
                    } else {
                        return true;
                    }
                }
            }
        }
---------------------------------------------------------------------------------

The invocation of  zk.create() should be under the if() branch like bellow
---------------------------------------------------------------------------------
if (list.size() < size) {
					zk.create(root + "/" + name, new byte[0],
							Ids.OPEN_ACL_UNSAFE,
						CreateMode.EPHEMERAL_SEQUENTIAL);

					mutex.wait();
				} else {
---------------------------------------------------------------------------------

The function leave() has a similar problem. And the invocation of zk.delete() should be as follows
---------------------------------------------------------------------------------
zk.delete(root + "/" + list.get(0), 0);
---------------------------------------------------------------------------------

Hope it can help other doc readers.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)