Github user jvwing commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/801#discussion_r73953981
  
    --- Diff: 
nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/AbstractS3Processor.java
 ---
    @@ -184,35 +194,59 @@ protected String getUrlForObject(final String bucket, 
final String key) {
         }
     
         protected final AccessControlList createACL(final ProcessContext 
context, final FlowFile flowFile) {
    -        final AccessControlList acl = new AccessControlList();
    +        // lazy-initialize ACL, as it should not be used if no properties 
were specified
    +        AccessControlList acl = null;
     
             final String ownerId = 
context.getProperty(OWNER).evaluateAttributeExpressions(flowFile).getValue();
             if (!StringUtils.isEmpty(ownerId)) {
                 final Owner owner = new Owner();
                 owner.setId(ownerId);
    +            if (acl == null) {
    +                acl = new AccessControlList();
    +            }
                 acl.setOwner(owner);
             }
     
             for (final Grantee grantee : 
createGrantees(context.getProperty(FULL_CONTROL_USER_LIST).evaluateAttributeExpressions(flowFile).getValue()))
 {
    +            if (acl == null) {
    +                acl = new AccessControlList();
    +            }
                 acl.grantPermission(grantee, Permission.FullControl);
             }
     
             for (final Grantee grantee : 
createGrantees(context.getProperty(READ_USER_LIST).evaluateAttributeExpressions(flowFile).getValue()))
 {
    +            if (acl == null) {
    +                acl = new AccessControlList();
    +            }
                 acl.grantPermission(grantee, Permission.Read);
             }
     
             for (final Grantee grantee : 
createGrantees(context.getProperty(WRITE_USER_LIST).evaluateAttributeExpressions(flowFile).getValue()))
 {
    +            if (acl == null) {
    +                acl = new AccessControlList();
    +            }
                 acl.grantPermission(grantee, Permission.Write);
             }
     
             for (final Grantee grantee : 
createGrantees(context.getProperty(READ_ACL_LIST).evaluateAttributeExpressions(flowFile).getValue()))
 {
    +            if (acl == null) {
    +                acl = new AccessControlList();
    +            }
                 acl.grantPermission(grantee, Permission.ReadAcp);
             }
     
             for (final Grantee grantee : 
createGrantees(context.getProperty(WRITE_ACL_LIST).evaluateAttributeExpressions(flowFile).getValue()))
 {
    +            if (acl == null) {
    +                acl = new AccessControlList();
    +            }
                 acl.grantPermission(grantee, Permission.WriteAcp);
             }
     
             return acl;
         }
    +
    +    protected final CannedAccessControlList createCannedACL(final 
ProcessContext context, final FlowFile flowFile) {
    +        final String cannedAcl = 
context.getProperty(CANNED_ACL).evaluateAttributeExpressions(flowFile).getValue();
    +        return (!StringUtils.isEmpty(cannedAcl)) ? 
CannedAccessControlList.valueOf(cannedAcl) : null;
    --- End diff --
    
    How about breaking this out into a few simpler if/else lines?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to