diff --git a/WHATSNEW b/WHATSNEW index 925349653..517d8cec9 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -234,6 +234,8 @@ Fixed bugs: * and could leave file handles open on invalid archives. Bugzilla report 34893. +* propertyset threw NPE with nested, mapped propertysets. + Other changes: -------------- diff --git a/src/etc/testcases/types/propertyset.xml b/src/etc/testcases/types/propertyset.xml index 68ce6c23a..3c2d2d8e3 100644 --- a/src/etc/testcases/types/propertyset.xml +++ b/src/etc/testcases/types/propertyset.xml @@ -52,4 +52,43 @@ exp="barB=BarB, fooA=FooA" got="${toString:my-set}"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/org/apache/tools/ant/types/PropertySet.java b/src/main/org/apache/tools/ant/types/PropertySet.java index a4710c017..4b6f19a36 100644 --- a/src/main/org/apache/tools/ant/types/PropertySet.java +++ b/src/main/org/apache/tools/ant/types/PropertySet.java @@ -282,6 +282,12 @@ public class PropertySet extends DataType { Hashtable props = prj == null ? getAllSystemProperties() : prj.getProperties(); + //quick & dirty, to make nested mapped p-sets work: + for (Enumeration e = setRefs.elements(); e.hasMoreElements();) { + PropertySet set = (PropertySet) e.nextElement(); + props.putAll(set.getProperties()); + } + if (getDynamic() || cachedNames == null) { names = new HashSet(); addPropertyNames(names, props); @@ -382,20 +388,7 @@ public class PropertySet extends DataType { * @return the referenced PropertySet. */ protected PropertySet getRef() { - if (!isChecked()) { - Stack stk = new Stack(); - stk.push(this); - dieOnCircularReference(stk, getProject()); - } - - Object o = getRefid().getReferencedObject(getProject()); - if (!(o instanceof PropertySet)) { - String msg = getRefid().getRefId() - + " doesn\'t denote a propertyset"; - throw new BuildException(msg); - } else { - return (PropertySet) o; - } + return (PropertySet) getCheckedRef(PropertySet.class, "propertyset"); } /** @@ -469,4 +462,5 @@ public class PropertySet extends DataType { } return b.toString(); } + } diff --git a/src/testcases/org/apache/tools/ant/types/PropertySetTest.java b/src/testcases/org/apache/tools/ant/types/PropertySetTest.java index b30dd3ca0..28164e7c4 100644 --- a/src/testcases/org/apache/tools/ant/types/PropertySetTest.java +++ b/src/testcases/org/apache/tools/ant/types/PropertySetTest.java @@ -36,4 +36,12 @@ public class PropertySetTest extends BuildFileTest { public void testReferenceToTwoReferences() { executeTarget("reference-to-two-references"); } + + public void testNestedMapped() { + executeTarget("nested-mapped"); + } + + public void testNestedMappedMapped() { + executeTarget("nested-mapped-mapped"); + } }