[cp-patches] FYI: Fix for CopyOnWriteArrayList (PR 31402)

Jeroen Frijters jeroen at sumatra.nl
Sat Mar 31 10:02:29 UTC 2007


Hi,

Committed.

Regards,
Jeroen

2007-03-31  Jeroen Frijters  <jeroen at frijters.net>

        PR classpath/31402:
        * java/util/concurrent/CopyOnWriteArrayList.java
        (remove): Fixed ArrayIndexOutOfBoundsException when index == 0.
-------------- next part --------------
Index: CopyOnWriteArrayList.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/concurrent/CopyOnWriteArrayList.java,v
retrieving revision 1.2
diff -u -r1.2 CopyOnWriteArrayList.java
--- CopyOnWriteArrayList.java	10 Dec 2006 20:25:46 -0000	1.2
+++ CopyOnWriteArrayList.java	31 Mar 2007 09:50:21 -0000
@@ -349,7 +349,8 @@
   {
     E[] data = this.data;
     E[] newData = (E[]) new Object[data.length - 1];
-    System.arraycopy(data, 0, newData, 0, index - 1);
+    if (index > 0)
+      System.arraycopy(data, 0, newData, 0, index - 1);
     System.arraycopy(data, index + 1, newData, index,
                      data.length - index - 1);
     E r = data[index];



More information about the Classpath-patches mailing list