git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278290 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -234,6 +234,8 @@ Fixed bugs: | |||||
| * <unzip> and <untar> could leave file handles open on invalid | * <unzip> and <untar> could leave file handles open on invalid | ||||
| archives. Bugzilla report 34893. | archives. Bugzilla report 34893. | ||||
| * propertyset threw NPE with nested, mapped propertysets. | |||||
| Other changes: | Other changes: | ||||
| -------------- | -------------- | ||||
| @@ -52,4 +52,43 @@ | |||||
| exp="barB=BarB, fooA=FooA" | exp="barB=BarB, fooA=FooA" | ||||
| got="${toString:my-set}"/> | got="${toString:my-set}"/> | ||||
| </target> | </target> | ||||
| <target name="nested-mapped"> | |||||
| <propertyset id="nested-mapped"> | |||||
| <propertyset> | |||||
| <propertyset refid="properties-starting-with-foo"/> | |||||
| <globmapper from="foo*" to="boo*" /> | |||||
| </propertyset> | |||||
| <propertyset> | |||||
| <propertyset refid="properties-starting-with-bar"/> | |||||
| <globmapper from="bar*" to="far*" /> | |||||
| </propertyset> | |||||
| </propertyset> | |||||
| <expect.equals | |||||
| test="nested mapped propertysets" | |||||
| exp="booA=FooA, farB=BarB" | |||||
| got="${toString:nested-mapped}"/> | |||||
| </target> | |||||
| <target name="nested-mapped-mapped"> | |||||
| <propertyset id="nested-mapped-mapped"> | |||||
| <propertyset> | |||||
| <propertyset refid="properties-starting-with-foo"/> | |||||
| <globmapper from="foo*" to="boo*" /> | |||||
| </propertyset> | |||||
| <propertyset> | |||||
| <propertyset refid="properties-starting-with-bar"/> | |||||
| <globmapper from="bar*" to="far*" /> | |||||
| </propertyset> | |||||
| <mapper> | |||||
| <globmapper from="boo*" to="hoo*" /> | |||||
| <globmapper from="far*" to="near*" /> | |||||
| </mapper> | |||||
| </propertyset> | |||||
| <expect.equals | |||||
| test="nested mapped propertysets" | |||||
| exp="hooA=FooA, nearB=BarB" | |||||
| got="${toString:nested-mapped-mapped}"/> | |||||
| </target> | |||||
| </project> | </project> | ||||
| @@ -282,6 +282,12 @@ public class PropertySet extends DataType { | |||||
| Hashtable props = | Hashtable props = | ||||
| prj == null ? getAllSystemProperties() : prj.getProperties(); | 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) { | if (getDynamic() || cachedNames == null) { | ||||
| names = new HashSet(); | names = new HashSet(); | ||||
| addPropertyNames(names, props); | addPropertyNames(names, props); | ||||
| @@ -382,20 +388,7 @@ public class PropertySet extends DataType { | |||||
| * @return the referenced PropertySet. | * @return the referenced PropertySet. | ||||
| */ | */ | ||||
| protected PropertySet getRef() { | 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(); | return b.toString(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -36,4 +36,12 @@ public class PropertySetTest extends BuildFileTest { | |||||
| public void testReferenceToTwoReferences() { | public void testReferenceToTwoReferences() { | ||||
| executeTarget("reference-to-two-references"); | executeTarget("reference-to-two-references"); | ||||
| } | } | ||||
| public void testNestedMapped() { | |||||
| executeTarget("nested-mapped"); | |||||
| } | |||||
| public void testNestedMappedMapped() { | |||||
| executeTarget("nested-mapped-mapped"); | |||||
| } | |||||
| } | } | ||||