From 7db902758895c1c83c8d48efbd4c9780f15e9e17 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 10 Aug 2000 08:56:14 +0000 Subject: [PATCH] Avoid NullPointerException in FileSet. Submitted by: Jeff Martin git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267915 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/types/FileSet.java | 4 ++++ .../org/apache/tools/ant/types/CommandlineTest.java | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/org/apache/tools/ant/types/FileSet.java b/src/main/org/apache/tools/ant/types/FileSet.java index 4781007f4..a1c610cb6 100644 --- a/src/main/org/apache/tools/ant/types/FileSet.java +++ b/src/main/org/apache/tools/ant/types/FileSet.java @@ -182,6 +182,10 @@ public class FileSet { * Returns the directory scanner needed to access the files to process. */ public DirectoryScanner getDirectoryScanner(Project p) { + if (dir == null) { + throw new BuildException("No directory specified for fileset."); + } + /* * XXX remove the check here and enable the one in setDir as soon * as we configure tasks at execution time. diff --git a/src/testcases/org/apache/tools/ant/types/CommandlineTest.java b/src/testcases/org/apache/tools/ant/types/CommandlineTest.java index ff2119f7e..d4a5ed9ea 100644 --- a/src/testcases/org/apache/tools/ant/types/CommandlineTest.java +++ b/src/testcases/org/apache/tools/ant/types/CommandlineTest.java @@ -115,9 +115,8 @@ public class CommandlineTest extends TestCase { // what the Unix sh does but causes a lot of problems on DOS // based platforms otherwise s = Commandline.translateCommandline("1 2\\ 3 4"); - assertEquals("case with quotes whitespace", 4, s.length); - assertEquals("Single quotes stripped, double quote included", "2\\", - s[1]); + assertEquals("case with quoted whitespace", 4, s.length); + assertEquals("backslash included", "2\\", s[1]); // now to the expected failures