Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Trivial Trivial
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: java client
    • Labels:
      None

      Description

      In org.apache.zookeeper:
      1) ZooDefs.Ids.OPEN_ACL_UNSAFE
      2) ZooDefs.Ids.CREATOR_ALL_ACL
      3) ZooDefs.Ids.READ_ALL_ACL
      are not immutable lists. Unlikely but the client could alter them.

        Activity

        Tassos Souris created issue -
        Hide
        Edward Ribeiro added a comment -

        All three fields are declared as follows:

        public final ArrayList<ACL> OPEN_ACL_UNSAFE = new ArrayList<ACL>( Collections.singletonList(new ACL(Perms.ALL, ANYONE_ID_UNSAFE)));

        The change would be a matter of just removing the ArrayList and declaring the field as a List as Collections.singletonList() already returns an immutable collection:

        public final List<ACL> OPEN_ACL_UNSAFE = Collections.singletonList(new ACL(Perms.ALL, ANYONE_ID_UNSAFE));

        Unfortunately, they are public fields, so I suppose it could pontentially broke many client apps that are referencing this field as

        ArrayList<ACL> perms = ZooDefs.Ids.OPEN_ACL_UNSAFE;

        I still think this change is doable, but I would like to hear what other people think.

        Show
        Edward Ribeiro added a comment - All three fields are declared as follows: public final ArrayList<ACL> OPEN_ACL_UNSAFE = new ArrayList<ACL>( Collections.singletonList(new ACL(Perms.ALL, ANYONE_ID_UNSAFE))); The change would be a matter of just removing the ArrayList and declaring the field as a List as Collections.singletonList() already returns an immutable collection: public final List<ACL> OPEN_ACL_UNSAFE = Collections.singletonList(new ACL(Perms.ALL, ANYONE_ID_UNSAFE)); Unfortunately, they are public fields, so I suppose it could pontentially broke many client apps that are referencing this field as ArrayList<ACL> perms = ZooDefs.Ids.OPEN_ACL_UNSAFE; I still think this change is doable, but I would like to hear what other people think.
        Hide
        Tassos Souris added a comment -

        or keep the ArrayList and use unmodifiableList:
        public final ArrayList<ACL> OPEN_ACL_UNSAFE = Collections.unmodifiableList( new ArrayList<ACL>(
        Collections.singletonList(new ACL(Perms.ALL, ANYONE_ID_UNSAFE))
        ));

        Show
        Tassos Souris added a comment - or keep the ArrayList and use unmodifiableList: public final ArrayList<ACL> OPEN_ACL_UNSAFE = Collections.unmodifiableList( new ArrayList<ACL>( Collections.singletonList(new ACL(Perms.ALL, ANYONE_ID_UNSAFE)) ));
        Hide
        Tassos Souris added a comment -

        ignore the above.. rushed to answer... can't delete it though

        Show
        Tassos Souris added a comment - ignore the above.. rushed to answer... can't delete it though
        Hide
        Patrick Hunt added a comment -

        That's unfortunate. We typically don't break b/w compatibility outside of a Major upgrade.

        Create an immutable ArrayList subclass? a proxy?

        Show
        Patrick Hunt added a comment - That's unfortunate. We typically don't break b/w compatibility outside of a Major upgrade. Create an immutable ArrayList subclass? a proxy?
        Hide
        Edward Ribeiro added a comment -

        Yep, we could go for the immutable ArrayList subclass, but I think it would be nice if this issue could be pushed to 4.x so that OPEN_ACL_USAFE and related could be declared as List<ACL> instead of ArrayList<ACL>.

        Show
        Edward Ribeiro added a comment - Yep, we could go for the immutable ArrayList subclass, but I think it would be nice if this issue could be pushed to 4.x so that OPEN_ACL_USAFE and related could be declared as List<ACL> instead of ArrayList<ACL>.

          People

          • Assignee:
            Unassigned
            Reporter:
            Tassos Souris
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development