ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peterrei...@apache.org
Subject svn commit: r573537 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/taskdefs/MacroInstance.java src/tests/antunit/bugfixes/ src/tests/antunit/bugfixes/README.txt src/tests/antunit/bugfixes/bugzilla-43324-stackoverflow-test.xml
Date Fri, 07 Sep 2007 10:52:33 GMT
Author: peterreilly
Date: Fri Sep  7 03:52:29 2007
New Revision: 573537

URL: http://svn.apache.org/viewvc?rev=573537&view=rev
Log:
Bugzilla: 43324 stackoverflow

Added:
    ant/core/trunk/src/tests/antunit/bugfixes/
    ant/core/trunk/src/tests/antunit/bugfixes/README.txt   (with props)
    ant/core/trunk/src/tests/antunit/bugfixes/bugzilla-43324-stackoverflow-test.xml   (with
props)
Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=573537&r1=573536&r2=573537&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Sep  7 03:52:29 2007
@@ -160,6 +160,9 @@
 * FilterMapper could throw an NPE.
   Bugzilla 43292.
 
+* Regession nested macrodefs with elements could cause StackOverFlow.
+  Bugzilla 43324.
+
 Other changes:
 --------------
 * <script> now has basic support for JavaFX scripts

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java?rev=573537&r1=573536&r2=573537&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/MacroInstance.java Fri Sep  7 03:52:29
2007
@@ -242,7 +242,7 @@
         this.text = text;
     }
 
-    private UnknownElement copy(UnknownElement ue) {
+    private UnknownElement copy(UnknownElement ue, boolean nested) {
         UnknownElement ret = new UnknownElement(ue.getTag());
         ret.setNamespace(ue.getNamespace());
         ret.setProject(getProject());
@@ -281,8 +281,8 @@
             }
             MacroDef.TemplateElement templateElement =
                 (MacroDef.TemplateElement) getNsElements().get(tag);
-            if (templateElement == null) {
-                UnknownElement child = copy(unknownElement);
+            if (templateElement == null || nested) {
+                UnknownElement child = copy(unknownElement, nested);
                 rc.addChild(child.getWrapper());
                 ret.addChild(child);
             } else if (templateElement.isImplicit()) {
@@ -293,7 +293,8 @@
                 }
                 for (Iterator i = unknownElements.iterator();
                      i.hasNext();) {
-                    UnknownElement child = copy((UnknownElement) i.next());
+                    UnknownElement child
+                        = copy((UnknownElement) i.next(), true);
                     rc.addChild(child.getWrapper());
                     ret.addChild(child);
                 }
@@ -317,7 +318,8 @@
                 if (list != null) {
                     for (Iterator i = list.iterator();
                          i.hasNext();) {
-                        UnknownElement child = copy((UnknownElement) i.next());
+                        UnknownElement child
+                            = copy((UnknownElement) i.next(), true);
                         rc.addChild(child.getWrapper());
                         ret.addChild(child);
                     }
@@ -386,7 +388,7 @@
         }
 
         // need to set the project on unknown element
-        UnknownElement c = copy(macroDef.getNestedTask());
+        UnknownElement c = copy(macroDef.getNestedTask(), false);
         c.init();
         try {
             c.perform();

Added: ant/core/trunk/src/tests/antunit/bugfixes/README.txt
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/bugfixes/README.txt?rev=573537&view=auto
==============================================================================
--- ant/core/trunk/src/tests/antunit/bugfixes/README.txt (added)
+++ ant/core/trunk/src/tests/antunit/bugfixes/README.txt Fri Sep  7 03:52:29 2007
@@ -0,0 +1,2 @@
+This directory contains tests for the bugs
+that have been fixed.

Propchange: ant/core/trunk/src/tests/antunit/bugfixes/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: ant/core/trunk/src/tests/antunit/bugfixes/bugzilla-43324-stackoverflow-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/bugfixes/bugzilla-43324-stackoverflow-test.xml?rev=573537&view=auto
==============================================================================
--- ant/core/trunk/src/tests/antunit/bugfixes/bugzilla-43324-stackoverflow-test.xml (added)
+++ ant/core/trunk/src/tests/antunit/bugfixes/bugzilla-43324-stackoverflow-test.xml Fri Sep
 7 03:52:29 2007
@@ -0,0 +1,51 @@
+<project name="length-test" default="antunit"
+         xmlns:au="antlib:org.apache.ant.antunit">
+
+  <import file="../antunit-base.xml" />
+
+  <target name="testnested">
+    <macrodef name="root-macro">
+      <element name="sub-tasks" optional="false" />
+
+      <sequential>
+        <!-- do stuff -->
+        <sub-tasks />
+      </sequential>
+    </macrodef>
+
+    <macrodef name="used-macro-a">
+      <element name="a-sub-tasks" optional="false" implicit="true" />
+
+      <sequential>
+        <root-macro>
+          <sub-tasks>
+            <!-- do stuff -->
+            <a-sub-tasks />
+          </sub-tasks>
+        </root-macro>
+      </sequential>
+    </macrodef>
+
+    <macrodef name="used-macro-b">
+      <element name="b-sub-tasks" optional="false" implicit="true" />
+
+      <sequential>
+        <used-macro-a>
+          <root-macro>
+            <sub-tasks>
+              <!-- do stuff -->
+              <b-sub-tasks />
+            </sub-tasks>
+          </root-macro>
+        </used-macro-a>
+      </sequential>
+    </macrodef>
+
+    <used-macro-b>
+      <echo message="Test B" />
+    </used-macro-b>
+
+    <au:assertLogContains text="Test B"/>
+  </target>
+
+</project>

Propchange: ant/core/trunk/src/tests/antunit/bugfixes/bugzilla-43324-stackoverflow-test.xml
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message