yandrey321 commented on code in PR #9427:
URL: https://github.com/apache/ozone/pull/9427#discussion_r2603612850


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/PrefixManagerImpl.java:
##########
@@ -235,33 +235,35 @@ public OMPrefixAclOpResult addAcl(OzoneObj ozoneObj, 
OzoneAcl ozoneAcl,
     // No explicit prefix create API, both add/set Acl can get new prefix
     // created. When new prefix is created, it should inherit parent prefix
     // or bucket default ACLs.
-    boolean newPrefix = false;
-    if (prefixInfo == null) {
-      OmPrefixInfo.Builder prefixInfoBuilder =
-          new OmPrefixInfo.Builder()
-          .setName(ozoneObj.getPath());
-      if (transactionLogIndex > 0) {
-        prefixInfoBuilder.setObjectID(OmUtils.getObjectIdFromTxId(
-            metadataManager.getOmEpoch(), transactionLogIndex));
-        prefixInfoBuilder.setUpdateID(transactionLogIndex);
-      }
-      prefixInfo = prefixInfoBuilder.build();
-      newPrefix = true;
+    boolean newPrefix = prefixInfo == null;
+    OmPrefixInfo.Builder prefixInfoBuilder = newPrefix
+        ? new OmPrefixInfo.Builder().setName(ozoneObj.getPath())
+        : prefixInfo.toBuilder();
+
+    if (newPrefix && transactionLogIndex > 0) {
+      prefixInfoBuilder.setObjectID(OmUtils.getObjectIdFromTxId(
+          metadataManager.getOmEpoch(), transactionLogIndex));
+      prefixInfoBuilder.setUpdateID(transactionLogIndex);
     }
 
-    boolean changed = prefixInfo.addAcl(ozoneAcl);
     // Update the in-memory prefix tree regardless whether the ACL is changed.
     // Under OM HA, update ID of the prefix info is updated for every request.
     if (newPrefix) {
-      inheritParentAcl(ozoneObj, prefixInfo);
+      List<OzoneAcl> inheritedAcls = new ArrayList<>();
+      inheritParentAcl(ozoneObj, inheritedAcls);
+      prefixInfoBuilder.addAcls(inheritedAcls);
     }
+    prefixInfoBuilder.addAcl(ozoneAcl);
+    boolean changed = prefixInfoBuilder.isAclsChanged();
+
+    OmPrefixInfo updatedPrefixInfo = prefixInfoBuilder.build();

Review Comment:
   Do we need to update if changed == false?



-- 
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]

Reply via email to