You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2022/06/23 12:45:00 UTC

[jira] [Commented] (IO-754) WildcardFileFilter should not ignore override accept-method

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

Gary D. Gregory commented on IO-754:
------------------------------------

[~sgessner] 

ping?

> WildcardFileFilter should not ignore override accept-method
> -----------------------------------------------------------
>
>                 Key: IO-754
>                 URL: https://issues.apache.org/jira/browse/IO-754
>             Project: Commons IO
>          Issue Type: Bug
>    Affects Versions: 2.9.0, 2.10.0, 2.11.0
>            Reporter: Sita Geßner
>            Priority: Major
>
> I have a method to filter files with different extensions in a directory.
> I did override the accept method for WildcardFileFilter because I want to check the filename in lowercase, to find files with different spellings of the fileextension.
> After updating commons-io from 2.8.0 to 2.11.0 the accept-method is ignored. The breakpoint won't stop in the accept-method.
> Here is my codeexample:
> {code:java}
>     public static void main(final String[] args) throws Exception {
>         final File directory = new File(FileUtils.getTempDirectory(), "TEST");
>         directory.mkdir();
>         new File(directory, "TEST").mkdir();
>         new File(directory, "test1.pdf").createNewFile();
>         new File(directory, "test1.txt").createNewFile();
>         new File(directory, "test2.PDF").createNewFile();
>         new File(directory, "test2.TXT").createNewFile();
>         final IOFileFilter filter = new WildcardFileFilter("*.pdf", "*.txt") {
>             private static final long serialVersionUID = 1L;
>             @Override
>             public boolean accept(final File file) {
>                 return super.accept(file, file.getName().toLowerCase());
>             }
>         };
>         for (final Iterator<File> itFiles = FileUtils.iterateFiles(directory, filter, null); itFiles
>                 .hasNext();) {
>             final File file = itFiles.next();
>             System.out.println(file.getAbsolutePath());
>         }
>     }
> {code}
> output in version 2.8.0:
> {noformat}
> /tmp/TEST/test2.PDF
> /tmp/TEST/test1.txt
> /tmp/TEST/test1.pdf
> /tmp/TEST/test2.TXT
> {noformat}
> output in version 2.9.0 or higher:
> {noformat}
> /tmp/TEST/test1.txt
> /tmp/TEST/test1.pdf
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)