Francçois-Xavier HENG created NIFI-7950:
-------------------------------------------

             Summary: TailFile processor in Multiple files mode cannot work on 
Windows.
                 Key: NIFI-7950
                 URL: https://issues.apache.org/jira/browse/NIFI-7950
             Project: Apache NiFi
          Issue Type: Bug
          Components: Core Framework
    Affects Versions: 1.12.1, 1.11.4
         Environment: Windows
            Reporter: Francçois-Xavier HENG


On windows TailFile can not work for "Tailing mode" = Multiple files.

I'm not good enough with apache lib to correct this alone but here is the 
faulty part:
In 
nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/TailFile.java,
 line 409:
 _  /**
     * Method to list the files to tail according to the given base directory
     * and using the user-provided regular expression
     * @param baseDir base directory to recursively look into
     * @param fileRegex expression regular used to match files to tail
     * @param isRecursive true if looking for file recursively, false otherwise
     * @return List of files to tail
     */_
    private List<String> getFilesToTail(final String baseDir, String fileRegex, 
boolean isRecursive, long maxAge) {
        final Collection<File> files = FileUtils.listFiles(new File(baseDir), 
null, isRecursive);
        final List<String> result = new ArrayList<String>();
        final String baseDirNoTrailingSeparator = 
baseDir.endsWith(File.separator) ? baseDir.substring(0, baseDir.length() - 1) : 
baseDir;
        final String fullRegex;
        if (File.separator.equals("/")) {
            // handle unix-style paths
            fullRegex = baseDirNoTrailingSeparator + File.separator + fileRegex;
        } else {
            // handle windows-style paths, need to quote backslash characters
            fullRegex = baseDirNoTrailingSeparator + 
Pattern.quote(File.separator) + fileRegex;
        }
        final Pattern p = Pattern.compile(fullRegex);

On windows the separator is the regexp exape char '\'. The windows path cannot 
be turn in a usable regexp.
Only workaround is to double slash the windows path after removing last 
trailing '\'.
Solution maybe to escape all separator in the variable 
baseDirNoTrailingSeparator.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to