You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@zookeeper.apache.org by "Houston Putman (Jira)" <ji...@apache.org> on 2022/03/22 16:32:00 UTC

[jira] [Created] (ZOOKEEPER-4500) ACL Lists cannot be validated when they are immutable

Houston Putman created ZOOKEEPER-4500:
-----------------------------------------

             Summary: ACL Lists cannot be validated when they are immutable
                 Key: ZOOKEEPER-4500
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-4500
             Project: ZooKeeper
          Issue Type: Bug
            Reporter: Houston Putman


Currently the validateACL() method in Zookeeper.java looks like this:

 
{code:java}
if (acl == null || acl.isEmpty() || acl.contains(null)) {
  throw new KeeperException.InvalidACLException();
} {code}
However the {{contains()}} method for an {{ImmutableCollection}} validates that the argument is non-null: (Note, {{contains()}}{{{} calls {{indexOf()}}{}}}{{{}){}}}

 

 
{code:java}
@Override
public int indexOf(Object o) {
    Objects.requireNonNull(o);
    for (int i = 0, s = size(); i < s; i++) {
        if (o.equals(get(i))) {
            return i;
        }
    }
    return -1;
} {code}
Therefore if you try to pass an immutable collection for ACLs, you will get a null-pointer exception.

 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)