Name: nt126004 Date: 01/15/2003
FULL PRODUCT VERSION :
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
When recursing through all folders on a drive, the 'System Volume Information' special directory is found on each
drive. File.isDirectory() returns true for this directory, but File.listFiles() returns null, contrary to the documentation.
This requires an extra null check which should not be necessary.
However, I do not have read access to this (System Volume Information)
directory. I am assuming that this falls into the second condition for
File.listFiles() returning a null, that an I/O error has occured.
I would have expected the method to throw an IOException in
this case, to indicate why the operation can't be completed, but I guess
that wouldn't really improve anything.
Perhaps the JavaDoc documentation could clarify the read access point?
"Returns: An array of abstract pathnames denoting the files and
directories in the directory denoted by this abstract pathname. The
array will be empty if the directory is empty. Returns null if this
abstract pathname does not denote a directory, or if an I/O error
occurs, for example, if the user does not have read access to the
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See source code. Run this method, starting with the root of each drive (using listRoots()).
EXPECTED VERSUS ACTUAL BEHAVIOR :
I would expect either: isDirectory() = false, if the System Volume Information is not regarded as a true directory,
or listFiles() to return an array (possibly empty) if System Volume Information _is_ regarded as a directory.
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public void scan(File file)
throws Exception // file must be a folder
File files = file.listFiles();
if (files != null)
for (int i = 0; i < files.length; i++)
System.out.println("Unexpected null file list for " + file);
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Test for null when calling listFiles()
(Review ID: 179095)