zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Huo Zhu (JIRA)" <j...@apache.org>
Subject [jira] [Created] (ZOOKEEPER-3221) WriteLock in recipes may get wrong child name as lock id
Date Tue, 18 Dec 2018 13:56:00 GMT
Huo Zhu created ZOOKEEPER-3221:

             Summary: WriteLock in recipes may get wrong child name as lock id
                 Key: ZOOKEEPER-3221
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3221
             Project: ZooKeeper
          Issue Type: Bug
          Components: recipes
         Environment: zookeeper-recipes-1.0
            Reporter: Huo Zhu

recently i used WriteLock in my application, and get following Exception
Exception in thread "produce 1" java.lang.IllegalArgumentException: Path must start with /
at org.apache.zookeeper.common.PathUtils.validatePath(PathUtils.java:51)
at org.apache.zookeeper.ZooKeeper.delete(ZooKeeper.java:851)
at org.apache.zookeeper.recipes.lock.WriteLock$1.execute(WriteLock.java:118)
at org.apache.zookeeper.recipes.lock.WriteLock$1.execute(WriteLock.java:1)
at org.apache.zookeeper.recipes.lock.WriteLock.unlock(WriteLock.java:122)
the following function is called when tried to lock,  used an existed child node name
as inner lock id, which may be conflict with another lock user, and at the same time the lock
id is just the node name , no with prefix path,  causing{color:#FF0000} java.lang.IllegalArgumentException{color}
in final delete operation. 
private  void findPrefixInChildren(String prefix, ZooKeeper zookeeper, String dir) throws
KeeperException, InterruptedException {
            List<String> names = zookeeper.getChildren(dir, false);
            for (String name : names) {
                if (name.startsWith(prefix)) {
                    id = name;
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Found id created last time: " + id);
            if (id == null) {
                id = zookeeper.create(dir + "/" + prefix, data,  getAcl(), EPHEMERAL_SEQUENTIAL);
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Created id: " + id);


This message was sent by Atlassian JIRA

View raw message