It looks like this change with by design for
https://issues.apache.org/jira/browse/IO-856
Gary
On 2024/12/30 17:54:17 "Gary D. Gregory" wrote:
> Hm, we'll have to look into that one. In the meantime, I added
>
> org.apache.commons.io.FileUtilsListFilesTest.testListFilesMissing()
>
> which asserts the current behavior in git master.
>
> TY,
> Gary
>
> On 2024/12/30 17:00:17 Dave Garratt wrote:
> >
> > I have recently tried updating from Commons IO 2.16.1 to Commons IO 2.18.0
> >
> > My java program constantly polls a folder for the presence of files.
> > Normally this will be a remote folder on a windows share.
> >
> > In Commons IO 2.16.1 when I use FileUtils.listFiles it would trigger an
> > exception if the folder being polled became unavailable and I would use
> > this to trigger an action.
> >
> > In Commons IO 2.18.0 the error does not occur.
> >
> > I have created a very simple test program to illustrate this.
> >
> > Running this code with Commons IO 2.16.1 and passing an invalid (non
> > existent) path to it gives me the following exception (which in my case is
> > desirable):
> >
> > import java.io.File;
> >
> > import org.apache.commons.io.FileUtils;
> >
> > public class Test2161
> > {
> >
> > public static void main(String[] args)
> > {
> > File dir = new File("/Users/dave/Downloads/nonexistent");
> >
> > try
> > {
> > FileUtils.listFiles(dir, args, false);
> > }
> > catch (Exception ex)
> > {
> > System.out.println(ex.getMessage());
> > ex.printStackTrace();
> > }
> > }
> > }
> >
> > java.nio.file.NoSuchFileException: /Users/dave/Downloads/nonexistent
> > java.io.UncheckedIOException: java.nio.file.NoSuchFileException:
> > /Users/dave/Downloads/nonexistent
> > at org.apache.commons.io.function.Uncheck.wrap(Uncheck.java:339)
> > at org.apache.commons.io.function.Uncheck.get(Uncheck.java:199)
> > at org.apache.commons.io.FileUtils.listFiles(FileUtils.java:2313)
> > at Test2161.main(Test2161.java:14)
> > Caused by: java.nio.file.NoSuchFileException:
> > /Users/dave/Downloads/nonexistent
> > at
> > java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
> > at
> > java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
> > at
> > java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
> > at
> > java.base/sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
> > at
> > java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:148)
> > at java.base/java.nio.file.Files.readAttributes(Files.java:1851)
> > at
> > java.base/java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:226)
> > at java.base/java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:277)
> > at java.base/java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:323)
> > at
> > java.base/java.nio.file.FileTreeIterator.<init>(FileTreeIterator.java:71)
> > at java.base/java.nio.file.Files.walk(Files.java:3918)
> > at org.apache.commons.io.file.PathUtils.walk(PathUtils.java:1847)
> > at org.apache.commons.io.FileUtils.streamFiles(FileUtils.java:2952)
> > at
> > org.apache.commons.io.FileUtils.lambda$listFiles$10(FileUtils.java:2313)
> > at org.apache.commons.io.function.Uncheck.get(Uncheck.java:197)
> > ... 2 more
> >
> >
> >
> > If however I run the same code with Commons IO 2.18.0 I get nothing, no
> > indication that the path is not valid which make it difficult to determine
> > if the folder is empty or the remote file server is shutdown.
> >
> > Am I supposed to use a different way to accomplish the same error condition
> > now ?
> >
> > Thanks
> >
> > Dave
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]