dineshchitlangia commented on a change in pull request #71: HDDS-2344. Add 
immutable entries in to the DoubleBuffer for Volume requests.
URL: https://github.com/apache/hadoop-ozone/pull/71#discussion_r337841329
 
 

 ##########
 File path: 
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmOzoneAclMap.java
 ##########
 @@ -298,4 +303,27 @@ public static OmOzoneAclMap ozoneAclGetFromProtobuf(
   public List<OzoneAclInfo> getDefaultAclList() {
     return defaultAclList;
   }
+
+  @Override
+  public Object clone() {
+    ArrayList<Map<String, BitSet>> accessMap = new ArrayList<>();
+
+    // Initialize.
+    for (OzoneAclType aclType : OzoneAclType.values()) {
+      accessMap.add(aclType.ordinal(), new HashMap<>());
+    }
+
+    // Add from original accessAclMap to accessMap.
+    for (OzoneAclType aclType : OzoneAclType.values()) {
+      final int ordinal = aclType.ordinal();
+      accessAclMap.get(ordinal).forEach((k, v) ->
+          accessMap.get(ordinal).put(k, (BitSet) v.clone()));
+    }
+
+    // We can do shallow copy here, as OzoneAclInfo is immutable structure.
+    ArrayList<OzoneAclInfo> defaultList = new ArrayList<>();
+    defaultList.addAll(defaultAclList);
+
+    return new OmOzoneAclMap(defaultList, accessMap);
+  }
 
 Review comment:
   OmOzoneAclMap.clone() does not call super.clone(). Thus the correct object 
type is not guaranteed here and violates the contract for clone(). Most likely 
this is the findbug issue listed in CI run. To fix this, you must call the 
super.clone()

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-dev-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-dev-h...@hadoop.apache.org

Reply via email to