You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/12/07 20:51:30 UTC

[GitHub] [nifi] NissimShiman commented on a change in pull request #4627: NIFI-7225 FetchSFTP processor routing to not.found error given when P…

NissimShiman commented on a change in pull request #4627:
URL: https://github.com/apache/nifi/pull/4627#discussion_r537823392



##########
File path: nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java
##########
@@ -848,8 +849,8 @@ public ValidationResult validate(final String subject, final String value, final
             }
 
             final File file = new File(substituted);
-            final boolean valid = file.exists();
-            final String explanation = valid ? null : "File " + file + " does not exist";
+            final boolean valid = file.exists() & !file.isDirectory();
+            final String explanation = valid ? null : "File " + file + " does not exist or is directory";
             return new ValidationResult.Builder().subject(subject).input(value).valid(valid).explanation(explanation).build();
         }

Review comment:
       @tlsmith See comment from @MikeThomsen [1] " Any refactored version would have to not change the current default behavior. So, what I'd suggest would be a second constructor that allows you to set a boolean flag to put in a "file-only" mode."
   
   I agree with this assessment and recommend this as well for this ticket. 
   
   [1] https://mail-archives.apache.org/mod_mbox/nifi-dev/202011.mbox/browser.  
   Subject: Re: FILE_EXISTS_VALIDATOR allows directories as well, is this a feature or a bug?

##########
File path: nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java
##########
@@ -848,8 +849,8 @@ public ValidationResult validate(final String subject, final String value, final
             }
 
             final File file = new File(substituted);
-            final boolean valid = file.exists();
-            final String explanation = valid ? null : "File " + file + " does not exist";
+            final boolean valid = file.exists() & !file.isDirectory();
+            final String explanation = valid ? null : "File " + file + " does not exist or is directory";
             return new ValidationResult.Builder().subject(subject).input(value).valid(valid).explanation(explanation).build();
         }

Review comment:
       @tlsmith109 Let's just put the file checking in customValidate() to be consistent with how it done in TailFile.java




----------------------------------------------------------------
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:
users@infra.apache.org