EdColeman commented on code in PR #3109:
URL: https://github.com/apache/accumulo/pull/3109#discussion_r1049838007


##########
server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader9to10.java:
##########
@@ -151,19 +152,9 @@ private static String extractAuthName(ACL acl) {
     }
   }
 
-  private static boolean canWrite(List<ACL> acls) {
-    if (ZooDefs.Ids.OPEN_ACL_UNSAFE.equals(acls)) {
-      return true;
-    }
-    ;
-    for (ACL acl : acls) {
-      String name = extractAuthName(acl);
-      if (("accumulo".equals(name) || "anyone".equals(name))
-          && acl.getPerms() >= ZooDefs.Perms.WRITE) {
-        return true;
-      }
-    }
-    return false;
+  private static boolean canWrite(final Set<String> users, final List<ACL> 
acls) {
+    return ZooDefs.Ids.OPEN_ACL_UNSAFE.equals(acls) || acls.stream()
+        .anyMatch(a -> users.contains(extractAuthName(a)) && a.getPerms() >= 
ZooDefs.Perms.WRITE);

Review Comment:
   The perms are bits - so `>= ZooDefs.Perms.WRITE` will return true if any 
combination of write, create, delete, admin is set - so if the perm was delete 
only, this would still return "true" for can write, which seems misleading at 
best.
   
   I think the test might be better names hasAll and the condition was:
   
   ```
    .anyMatch(a -> users.contains(extractAuthName(a)) && a.getPerms() == 
ZooDefs.Perms.ALL;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to