DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26737>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26737

Directory Scanner failure

           Summary: Directory Scanner failure
           Product: Ant
           Version: 1.6.0
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core tasks
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I have produced a situation in which the following piece of code towards the 
beginning of DirectoryScanner.scanDir throws the exception:

        String[] newfiles = dir.list();

        if (newfiles == null) {
            /*
             * two reasons are mentioned in the API docs for File.list
             * (1) dir is not a directory. This is impossible as
             *     we wouldn't get here in this case.
             * (2) an IO error occurred (why doesn't it throw an exception
             *     then???)
             */
            throw new BuildException("IO error scanning directory "
                                     + dir.getAbsolutePath());
        }

Note that (1), alas, is not true. If the directory name is like this:
   "some/directory "  [ note space on the end ]
and 
   "some/directory"   [ note no space ]
is a valid direcotory then this exception is thrown. 

Perhaps you trim the string before testing for existance? Both 
File.isDirectory and File.exists return false for the string with the trailing 
space.

It would be nice if you checked for this condition (i.e., leading or triling 
space). The trailing space is very easy to produce if a directory name or 
componenet thereof is loaded from a file and very difficult diagnose from just 
the IOError thrown. The only reason I managed to find it was that (1) I looked 
at the source (2) had previous encounters with the vagaries of File.list.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to