Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-740

RegexFileFilter matches on full path instead of filename

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.9.0
    • Fix Version/s: 2.10.0
    • Component/s: Filters
    • Labels:
      None

      Description

      org.apache.commons.io.filefilter.RegexFileFilter#accept(java.nio.file.Path, java.nio.file.attribute.BasicFileAttributes) is a new method added in 2.9.0 and it's javadoc states: 

      /**
       * Checks to see if the file name matches one of the regular expressions.
       *
       * @param path the path
       * @param attributes the path attributes
       * @return true if the file name matches one of the regular expressions
       */
      

      However in it's implementation: 

      return toFileVisitResult(pattern.matcher(path.toString()).matches(), path);
      

      it matches on path.toString() which will be the full path instead of the filename.

       

      This is also inconsistent with the other method  org.apache.commons.io.filefilter.RegexFileFilter#accept(java.io.File, java.lang.String) which does match only on filename.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                tomjo Tom Jorissen
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: