[
https://issues.apache.org/jira/browse/IO-754?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gary D. Gregory updated IO-754:
-------------------------------
Assignee: Gary D. Gregory
> 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
> Assignee: Gary D. Gregory
> 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
(v10.3.26#10030026)