walkFileTree() does not throw NPE for null FileVisitOption
Alan Bateman
Alan.Bateman at Sun.COM
Fri Aug 8 06:36:42 PDT 2008
Rajendra Gutupalli wrote:
> Hi Alan,
>
> I added null value to the set of FileVisitOption and passed it as an
> argument to Files.walkFileTree(). Right now it works without throwing
> NPE.
> Should the following code throw NPE or ignore null value?
>
> Set<FileVisitOption> visitOpts = new HashSet<FileVisitOption>();
> visitOpts.add(null);
> Files.walkFileTree(path, visitOpts, -1, new MyFileVisitor());
>
> Usually if we pass array/set of open/copy options which contain null
> value then the respective method (moveTo/newSeekableChannel ..) throws
> NPE.
There's a section in the package description to specify that the default
behavior (ie: unless otherwise specified) is that NPE is thrown if a
method is invoked with a null parameter or with a collection that
contains null. I'll fix this for the next build - thanks!
-Alan.
More information about the nio-dev
mailing list