You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Tom Jorissen (Jira)" <ji...@apache.org> on 2021/06/11 13:02:00 UTC

[jira] [Commented] (IO-740) RegexFileFilter matches on full path instead of filename

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

Tom Jorissen commented on IO-740:
---------------------------------

Sorry, I searched for issues with RegexFileFilter before and nothing showed up but now I see multiple..

> RegexFileFilter matches on full path instead of filename
> --------------------------------------------------------
>
>                 Key: IO-740
>                 URL: https://issues.apache.org/jira/browse/IO-740
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Filters
>    Affects Versions: 2.9.0
>            Reporter: Tom Jorissen
>            Priority: Minor
>             Fix For: 2.10.0
>
>
> 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: 
> {code:java}
> /**
>  * 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
>  */
> {code}
> However in it's implementation: 
> {code:java}
> return toFileVisitResult(pattern.matcher(path.toString()).matches(), path);
> {code}
> 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.



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