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

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

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

Enrico Olivelli commented on ZOOKEEPER-4500:
--------------------------------------------

Good catch.

 

What about sending a patch?

> 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
>            Priority: Major
>
> 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)