harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r801087 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/AbstractList.java test/api/common/org/apache/harmony/luni/tests/java/util/AbstractListTest.java
Date Wed, 05 Aug 2009 08:44:09 GMT
Author: regisxu
Date: Wed Aug  5 08:44:08 2009
New Revision: 801087

URL: http://svn.apache.org/viewvc?rev=801087&view=rev
Log:
Apply patch for HARMONY-6292: [classlib][luni] subList(int, int).size() should also check
concurrent modification when the origin changes

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractListTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java?rev=801087&r1=801086&r2=801087&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/AbstractList.java
Wed Aug  5 08:44:08 2009
@@ -360,7 +360,10 @@
 
         @Override
         public int size() {
-            return size;
+            if (modCount == fullList.modCount) {
+                return size;
+            }
+            throw new ConcurrentModificationException();
         }
 
         void sizeChanged(boolean increment) {

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractListTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractListTest.java?rev=801087&r1=801086&r2=801087&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractListTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/AbstractListTest.java
Wed Aug  5 08:44:08 2009
@@ -345,4 +345,89 @@
     		//Excepted to catch IllegalStateException here
     	}
     }
+
+    public void test_subListII2() {
+        List<Integer> holder = new ArrayList<Integer>(16);
+        for (int i=0; i<10; i++) {
+            holder.add(i);
+        }
+
+        // parent change should cause sublist concurrentmodification fail
+        List<Integer> sub = holder.subList(0, holder.size());
+        holder.add(11);
+        try {
+            sub.size();
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.add(12);
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.add(0, 11);
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.clear();
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.contains(11);
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.get(9);
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.indexOf(10);
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.isEmpty();
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.iterator();
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.lastIndexOf(10);
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.listIterator();
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.listIterator(0);
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.remove(0);
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.remove(9);
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.set(0, 0);
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.size();
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.toArray();
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+        try {
+            sub.toString();
+            fail("Should throw ConcurrentModificationException.");
+        } catch (ConcurrentModificationException e) {}
+
+        holder.clear();
+    }
 }



Mime
View raw message