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

    https://github.com/apache/nifi/pull/2007#discussion_r128689940
  
    --- Diff: 
nifi-nar-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/PutHDFS.java
 ---
    @@ -386,11 +388,14 @@ public void process(InputStream in) throws 
IOException {
             });
         }
     
    -    protected void changeOwner(final ProcessContext context, final 
FileSystem hdfs, final Path name) {
    +    protected void changeOwner(final ProcessContext context, final 
FileSystem hdfs, final Path name, final FlowFile flowFile) {
             try {
                 // Change owner and group of file if configured to do so
    -            String owner = context.getProperty(REMOTE_OWNER).getValue();
    -            String group = context.getProperty(REMOTE_GROUP).getValue();
    +//            String owner = context.getProperty(REMOTE_OWNER).getValue();
    +//            String group = context.getProperty(REMOTE_GROUP).getValue();
    +            String owner = 
context.getProperty(REMOTE_OWNER).evaluateAttributeExpressions(flowFile).getValue();
    +            String group = 
context.getProperty(REMOTE_GROUP).evaluateAttributeExpressions(flowFile).getValue();
    +
                 if (owner != null || group != null) {
    --- End diff --
    
    When I tested with an expression that returns no value, e.g. specify an 
attribute name which does not exist, then the group string became an Empty 
string. And the file was updated with an empty group. To avoid that, Could you 
add following code before this if statement? to make empty string into null:
    
    ```
                owner = owner == null || owner.isEmpty() ? null : owner;
                group = group == null || group.isEmpty() ? null : group;
    ```
    
    
![image](https://user-images.githubusercontent.com/1107620/28451433-3b1718a2-6e28-11e7-9473-282bbfcdd881.png)



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