adoroszlai commented on code in PR #6396:
URL: https://github.com/apache/ozone/pull/6396#discussion_r1528656938
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java:
##########
@@ -99,6 +95,12 @@ private static BitSet validateAndCopy(BitSet acls) {
return copyBitSet(acls);
}
+ private static BitSet validateAndCopy(EnumSet<ACLType> enumSet) {
+ BitSet aclBitSet = new BitSet();
+ enumSet.forEach(aclType -> aclBitSet.set(aclType.ordinal()));
+ return validateAndCopy(aclBitSet);
+ }
Review Comment:
- `BitSet` needs to be copied only when provided by external code (one that
creates `OzoneAcl`).
- We can reuse `bitSetOf(ACLType...)` to create the `BitSet`. One of the
methods can call the other, e.g. `Arrays.asList(acls)` (and declare this method
to accept any `Collection<ACLType>`) or `enumSet.toArray(new ACLType[0])`.
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OzoneAcl.java:
##########
@@ -170,7 +172,7 @@ public static OzoneAcl parseAcl(String acl)
// TODO : Support sanitation of these user names by calling into
// userAuth Interface.
- return new OzoneAcl(aclType, parts[1], acls, aclScope);
+ return new OzoneAcl(aclType, parts[1], aclScope, validateAndCopy(acls));
Review Comment:
Here `validateAndCopy` can be ommitted, since the `BitSet` is created in
`OzoneAcl`. Better yet, construct an `EnumSet`.
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestOzoneRpcClientAbstract.java:
##########
@@ -3444,11 +3444,8 @@ public void testNativeAclsForPrefix() throws Exception {
.setStoreType(OzoneObj.StoreType.OZONE)
.build();
- // add acl
- BitSet aclRights1 = new BitSet();
- aclRights1.set(READ.ordinal());
OzoneAcl user1Acl = new OzoneAcl(USER,
- "user1", aclRights1, ACCESS);
+ "user1", EnumSet.of(READ), ACCESS);
Review Comment:
We can avoid wrapping in `EnumSet` if the set is not reused.
```suggestion
"user1", ACCESS, READ);
```
(Also in a few other places, look for inline `EnumSet`.)
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]