From e2a75898e88825b87310be19070b68f967ae000c Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 10 Aug 2000 08:49:58 +0000 Subject: [PATCH] avoid NullPointerException in DirectoryScanner.scandir. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267914 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/DirectoryScanner.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/org/apache/tools/ant/DirectoryScanner.java b/src/main/org/apache/tools/ant/DirectoryScanner.java index 54a2209fd..cc506b983 100644 --- a/src/main/org/apache/tools/ant/DirectoryScanner.java +++ b/src/main/org/apache/tools/ant/DirectoryScanner.java @@ -727,6 +727,19 @@ strLoop: */ private void scandir(File dir, String vpath, boolean fast) { 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()); + } + for (int i = 0; i < newfiles.length; i++) { String name = vpath+newfiles[i]; File file = new File(dir,newfiles[i]);