diff --git a/WHATSNEW b/WHATSNEW index f6e0dbd49..b20a7d19e 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -4,6 +4,12 @@ Changes from Ant 1.8.2 TO Ant 1.8.3 Changes that could break older environments: ------------------------------------------- + * The Enumeration returned by AntClassLoader#getResources used to + return null in nextElement after hasNextElement would return false. + It has been changed to throw a NoSuchElementException instead so + that it now adheres to the contract of java.util.Enumeration. + Bugzilla Report 51579. + Fixed bugs: ----------- diff --git a/src/main/org/apache/tools/ant/AntClassLoader.java b/src/main/org/apache/tools/ant/AntClassLoader.java index e5086ffaa..06ec892f4 100644 --- a/src/main/org/apache/tools/ant/AntClassLoader.java +++ b/src/main/org/apache/tools/ant/AntClassLoader.java @@ -33,6 +33,7 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.Hashtable; import java.util.Map; +import java.util.NoSuchElementException; import java.util.StringTokenizer; import java.util.Vector; import java.util.jar.Attributes; @@ -127,6 +128,9 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { */ public Object nextElement() { URL ret = this.nextResource; + if (ret == null) { + throw new NoSuchElementException(); + } findNextResource(); return ret; }