summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-08-11 04:06:37 (EDT)
committerCaspar De Groot2010-08-11 04:06:37 (EDT)
commit4e8484a0e6c5ffac5074161aab98fc1ec4c2664c (patch)
tree56059801e048b1518b70eb355737751af5de2249
parent79f512d82062a61089ea4622ea47313b7a048d9c (diff)
downloadcdo-4e8484a0e6c5ffac5074161aab98fc1ec4c2664c.zip
cdo-4e8484a0e6c5ffac5074161aab98fc1ec4c2664c.tar.gz
cdo-4e8484a0e6c5ffac5074161aab98fc1ec4c2664c.tar.bz2
[322277] Math error in FastList.remove(Object)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=322277
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/FastListTest.java19
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/FastList.java3
2 files changed, 21 insertions, 1 deletions
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/FastListTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/FastListTest.java
index 57a42a3..429d347 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/FastListTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/FastListTest.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Caspar De Groot - maintenance
*/
package org.eclipse.net4j.util.tests;
@@ -109,6 +110,24 @@ public class FastListTest extends AbstractOMTest
assertEquals(true, result[5] == 8);
}
+ public void testRemoveMiddleOfThree()
+ {
+ TestList list = new TestList();
+ Integer one = new Integer(1);
+ Integer two = new Integer(2);
+ Integer three = new Integer(3);
+
+ list.add(one);
+ list.add(two);
+ list.add(three);
+
+ list.remove(two);
+
+ Integer[] elements = list.get();
+ assertSame(one, elements[0]);
+ assertSame(three, elements[1]);
+ }
+
public static void testRemoveTail() throws Exception
{
TestList list = new TestList();
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/FastList.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/FastList.java
index ea5d463..70a8a3e 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/FastList.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/FastList.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Caspar De Groot
*/
package org.eclipse.net4j.util.collection;
@@ -79,7 +80,7 @@ public abstract class FastList<E>
System.arraycopy(elements, 0, array, 0, i);
}
- if (i + 1 < length - 1)
+ if (i + 1 <= length - 1)
{
System.arraycopy(elements, i + 1, array, i, length - 1 - i);
}