summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2010-08-11 03:49:41 (EDT)
committerCaspar De Groot2010-08-11 03:49:41 (EDT)
commit0de654ae08c04f70c6ed81bb02f9441dfcc91b16 (patch)
tree33709798c120c9731e01832298c12f92bbfeda89
parent10e1f4d073149c22c777cd7da6d7a9998b953a68 (diff)
downloadcdo-0de654ae08c04f70c6ed81bb02f9441dfcc91b16.zip
cdo-0de654ae08c04f70c6ed81bb02f9441dfcc91b16.tar.gz
cdo-0de654ae08c04f70c6ed81bb02f9441dfcc91b16.tar.bz2
[322308] Math error in FastList.remove(Object)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=322308
-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.java2
2 files changed, 20 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 f6ed0b2..f12a216 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..79d5b94 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
@@ -79,7 +79,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);
}