From 09ada7b0d50685666a79bdb6e21214528165c5d0 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Wed, 8 Oct 2008 15:20:53 +0000 Subject: [PATCH] don't trust Vector's implemenation too much. Tests passed in JDK 1.4.2 but failed on Java 6, now pass on both. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@702907 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/util/VectorSet.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/org/apache/tools/ant/util/VectorSet.java b/src/main/org/apache/tools/ant/util/VectorSet.java index ee5102f98..ca6b75695 100644 --- a/src/main/org/apache/tools/ant/util/VectorSet.java +++ b/src/main/org/apache/tools/ant/util/VectorSet.java @@ -41,8 +41,9 @@ public class VectorSet extends Vector { private final HashSet set = new HashSet(); public synchronized boolean add(Object o) { - if (set.add(o)) { - return super.add(o); + if (!set.contains(o)) { + doAdd(size(), o); + return true; } return false; } @@ -70,8 +71,8 @@ public class VectorSet extends Vector { } } - public void addElement(Object o) { - add(o); + public synchronized void addElement(Object o) { + doAdd(size(), o); } public synchronized boolean addAll(Collection c) { @@ -90,11 +91,10 @@ public class VectorSet extends Vector { boolean changed = false; for (Iterator i = c.iterator(); i.hasNext(); ) { Object o = i.next(); - boolean added = set.add(o); - if (added) { - super.add(index++, o); + if (!set.contains(o)) { + doAdd(index++, o); + changed = true; } - changed |= added; } return changed; } @@ -190,7 +190,7 @@ public class VectorSet extends Vector { public synchronized Object set(int index, Object o) { Object orig = get(index); if (set.add(o)) { - super.set(index, o); + elementData[index] = o; set.remove(orig); } else { int oldIndexOfO = indexOf(o);