Source:
<code>public boolean addAcl(OzoneObj obj, OzoneAcl acl) throws IOException { Objects.requireNonNull(obj); Objects.requireNonNull(acl); if (!obj.getResourceType().equals(OzoneObj.ResourceType.BUCKET)) { throw new IllegalArgumentException("Unexpected argument passed to " + "BucketManager. OzoneObj type:" + obj.getResourceType()); } String volume = obj.getVolumeName(); String bucket = obj.getBucketName(); metadataManager.getLock().acquireBucketLock(volume, bucket); try { String dbBucketKey = metadataManager.getBucketKey(volume, bucket); OmBucketInfo bucketInfo = metadataManager.getBucketTable().get(dbBucketKey); if (bucketInfo == null) { LOG.debug("Bucket:{}/{} does not exist", volume, bucket); throw new OMException("Bucket " + bucket + " is not found", BUCKET_NOT_FOUND); } List<OzoneAcl> list = bucketInfo.getAcls(); <START> list.add(acl); <END> OmBucketInfo updatedBucket = OmBucketInfo.newBuilder() .setVolumeName(bucketInfo.getVolumeName()) .setBucketName(bucketInfo.getBucketName()) .setStorageType(bucketInfo.getStorageType()) .setIsVersionEnabled(bucketInfo.getIsVersionEnabled()) .setCreationTime(bucketInfo.getCreationTime()) .setBucketEncryptionKey(bucketInfo.getEncryptionKeyInfo()) .addAllMetadata(bucketInfo.getMetadata()) .setAcls(list) .build(); metadataManager.getBucketTable().put(dbBucketKey, updatedBucket); } catch (IOException ex) { if (!(ex instanceof OMException)) { LOG.error("Add acl operation failed for bucket:{}/{} acl:{}", volume, bucket, acl, ex); } throw ex; } finally { metadataManager.getLock().releaseBucketLock(volume, bucket); } return true; }</code><technical_language>Do need some sanity check avoid newly added acls conflict existing ones</technical_language>

Target:
public boolean addAcl(OzoneObj obj, OzoneAcl acl) throws IOException { Objects.requireNonNull(obj); Objects.requireNonNull(acl); if (!obj.getResourceType().equals(OzoneObj.ResourceType.BUCKET)) { throw new IllegalArgumentException("Unexpected argument passed to " + "BucketManager. OzoneObj type:" + obj.getResourceType()); } String volume = obj.getVolumeName(); String bucket = obj.getBucketName(); metadataManager.getLock().acquireBucketLock(volume, bucket); try { String dbBucketKey = metadataManager.getBucketKey(volume, bucket); OmBucketInfo bucketInfo = metadataManager.getBucketTable().get(dbBucketKey); if (bucketInfo == null) { LOG.debug("Bucket:{}/{} does not exist", volume, bucket); throw new OMException("Bucket " + bucket + " is not found", BUCKET_NOT_FOUND); } List<OzoneAcl> list = bucketInfo.getAcls(); if(!validateAddAcl(acl, list)) { LOG.info("New acl:{} can't be added as it is not consistent with " + "existing ACLs:{}.", acl, StringUtils.join(",", list)); return false; } list.add(acl); OmBucketInfo updatedBucket = OmBucketInfo.newBuilder() .setVolumeName(bucketInfo.getVolumeName()) .setBucketName(bucketInfo.getBucketName()) .setStorageType(bucketInfo.getStorageType()) .setIsVersionEnabled(bucketInfo.getIsVersionEnabled()) .setCreationTime(bucketInfo.getCreationTime()) .setBucketEncryptionKey(bucketInfo.getEncryptionKeyInfo()) .addAllMetadata(bucketInfo.getMetadata()) .setAcls(list) .build(); metadataManager.getBucketTable().put(dbBucketKey, updatedBucket); } catch (IOException ex) { if (!(ex instanceof OMException)) { LOG.error("Add acl operation failed for bucket:{}/{} acl:{}", volume, bucket, acl, ex); } throw ex; } finally { metadataManager.getLock().releaseBucketLock(volume, bucket); } return true; }