diff --git a/WHATSNEW b/WHATSNEW index 8076df1f6..a2d325e51 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -26,6 +26,9 @@ Fixed bugs: * The junit task when used with includeantruntime="no" was incorrectly printing a warning about multiple versions of ant detected in path + * died with a NullPointerException since Ant 1.10.2. + Bugzilla Report 62335 + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java b/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java index ebc46e287..3dbca7d34 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java @@ -52,6 +52,7 @@ public class Cab extends MatchingTask { private boolean doCompress = true; private boolean doVerbose = false; private String cmdOptions; + private boolean filesetAdded = false; // CheckStyle:VisibilityModifier OFF - bc protected String archiveType = "cab"; @@ -59,10 +60,6 @@ public class Cab extends MatchingTask { private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - { - fileset = null; - } - /** * The name/location of where to create the .cab file. * @param cabFile the location of the cab file. @@ -108,9 +105,10 @@ public class Cab extends MatchingTask { * @param fileset a set of files to archive. */ public void addFileset(FileSet fileset) { - if (fileset != null) { + if (filesetAdded) { throw new BuildException("Only one nested fileset allowed"); } + filesetAdded = true; this.fileset = fileset; } @@ -124,7 +122,7 @@ public class Cab extends MatchingTask { * @throws BuildException on error. */ protected void checkConfiguration() throws BuildException { - if (baseDir == null && fileset == null) { + if (baseDir == null && !filesetAdded) { throw new BuildException( "basedir attribute or one nested fileset is required!", getLocation()); @@ -132,7 +130,7 @@ public class Cab extends MatchingTask { if (baseDir != null && !baseDir.exists()) { throw new BuildException("basedir does not exist!", getLocation()); } - if (baseDir != null && fileset != null) { + if (baseDir != null && filesetAdded) { throw new BuildException( "Both basedir attribute and a nested fileset is not allowed"); }