Details
-
Bug
-
Status: Open
-
Critical
-
Resolution: Unresolved
-
None
-
None
-
None
-
zookeeper-recipes-1.0
Description
recently i used WriteLock in my application, and get following Exception
Exception in thread "produce 1" java.lang.IllegalArgumentException: Path must start with / character
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 java.lang.IllegalArgumentException 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); } break; } } if (id == null) { id = zookeeper.create(dir + "/" + prefix, data, getAcl(), EPHEMERAL_SEQUENTIAL); if (LOG.isDebugEnabled()) { LOG.debug("Created id: " + id); } } }
Attachments
Issue Links
- Blocked
-
ZOOKEEPER-645 Bug in WriteLock recipe implementation?
- Open