From baf4809c2c0eea1949cfabefe6b954f30150f1c2 Mon Sep 17 00:00:00 2001 From: Peter Reilly Date: Tue, 15 Jul 2003 09:05:53 +0000 Subject: [PATCH] use for loop instead of iterator when walking the list of tasks, this allows tasks to be added to the current list while the list is being walked. Revert the script test that failed when it was adding to the current task to test the change git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274822 13f79535-47bb-0310-9956-ffa450edef68 --- src/etc/testcases/taskdefs/optional/script.xml | 2 +- src/main/org/apache/tools/ant/Target.java | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/etc/testcases/taskdefs/optional/script.xml b/src/etc/testcases/taskdefs/optional/script.xml index fc54325db..884dc5a01 100644 --- a/src/etc/testcases/taskdefs/optional/script.xml +++ b/src/etc/testcases/taskdefs/optional/script.xml @@ -10,7 +10,7 @@ for (i=1; i<=10; i++) { echo = testproject.createTask("echo"); - example1.addTask(echo); + setup1.addTask(echo); echo.setMessage(i*i); } diff --git a/src/main/org/apache/tools/ant/Target.java b/src/main/org/apache/tools/ant/Target.java index 1433aa249..a1967e5f9 100644 --- a/src/main/org/apache/tools/ant/Target.java +++ b/src/main/org/apache/tools/ant/Target.java @@ -311,9 +311,8 @@ public class Target implements TaskContainer { */ public void execute() throws BuildException { if (testIfCondition() && testUnlessCondition()) { - Iterator it = children.iterator(); - while (it.hasNext()) { - Object o = it.next(); + for (int i = 0; i < children.size(); ++i) { + Object o = children.get(i); if (o instanceof Task) { Task task = (Task) o; task.perform();