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



##########
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:
       After discussions with @tlsmith109, I stand corrected.  This is very 
much relevant to this ticket.
   
   My only question is why the apache nifi community hasn't noticed this 
sooner.  Maybe they have, but have left it on purpose to make sure everything 
works with backward compatibility?
   
   @pvillard31 I noticed when you were working on TailFile in 
https://issues.apache.org/jira/browse/NIFI-1170 , when wishing to enforce that 
a filename is not a directory, you chose to check the validation in  
customValidate() [1]  as opposed to modifying FileExistsValidator to not 
validate directories.
   
   Was this by design to allow FileExistsValidator to validate directories?
   
   [1] 
https://github.com/apache/nifi/blob/main/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/TailFile.java#L288-L293
   




----------------------------------------------------------------
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:
[email protected]


Reply via email to