[ 
https://issues.apache.org/jira/browse/NIFI-4184?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16095843#comment-16095843
 ] 

ASF GitHub Bot commented on NIFI-4184:
--------------------------------------

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)



>  I needed to put some attributes on REMOTE_GROUP and REMOTE_OWNER in the 
> PutHDFS Processor
> ------------------------------------------------------------------------------------------
>
>                 Key: NIFI-4184
>                 URL: https://issues.apache.org/jira/browse/NIFI-4184
>             Project: Apache NiFi
>          Issue Type: Improvement
>            Reporter: dav
>
>  I needed to put some attributes on REMOTE_GROUP and REMOTE_OWNER in order to 
> achieve it i put expressionLanguageSupported(true) on the PropertyDescriptor 
> of REMOTE_GROUP and REMOTE_OWNER



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to