harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r996814 - in /harmony/enhanced/java/trunk/classlib/modules/luni/src: main/java/java/util/ArrayList.java test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java
Date Tue, 14 Sep 2010 10:24:49 GMT
Author: odeakin
Date: Tue Sep 14 10:24:48 2010
New Revision: 996814

URL: http://svn.apache.org/viewvc?rev=996814&view=rev
Log:
Fix edge case failure caused by change to ensureCapacity() at revision r982498. Just revert
to the original code for that method and add regression test case.

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

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/util/ArrayList.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/util/ArrayList.java?rev=996814&r1=996813&r2=996814&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/util/ArrayList.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/util/ArrayList.java
Tue Sep 14 10:24:48 2010
@@ -326,14 +326,13 @@ public class ArrayList<E> extends Abstra
      *            the minimum capacity asked for.
      */
     public void ensureCapacity(int minimumCapacity) {
-        int required = minimumCapacity - array.length;
-        if (required > 0) {
+        if (array.length < minimumCapacity) {
             // REVIEW: Why do we check the firstIndex first? Growing
             //         the end makes more sense
             if (firstIndex > 0) {
-                growAtFront(required);
+                growAtFront(minimumCapacity - array.length);
             } else {
-                growAtEnd(required);
+                growAtEnd(minimumCapacity - array.length);
             }
         }
     }

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java?rev=996814&r1=996813&r2=996814&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ArrayListTest.java
Tue Sep 14 10:24:48 2010
@@ -546,6 +546,10 @@ public class ArrayListTest extends junit
         al.ensureCapacity(capacity + 2);
         assertTrue("EnsureCapacity did not change location.", location == al
                 .indexOf(testObject));
+
+        ArrayList<String> list = new ArrayList<String>(1);
+        list.add("hello");
+        list.ensureCapacity(Integer.MIN_VALUE);
     }
 
     /**



Mime
View raw message