You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by sm...@apache.org on 2012/04/11 11:24:22 UTC

svn commit: r1324665 - in /pivot/trunk/core/src/org/apache/pivot/collections: ArrayList.java LinkedList.java

Author: smartini
Date: Wed Apr 11 09:24:22 2012
New Revision: 1324665

URL: http://svn.apache.org/viewvc?rev=1324665&view=rev
Log:
additional checks in verifyIndexBounds

Modified:
    pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java
    pivot/trunk/core/src/org/apache/pivot/collections/LinkedList.java

Modified: pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java?rev=1324665&r1=1324664&r2=1324665&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/collections/ArrayList.java Wed Apr 11 09:24:22 2012
@@ -573,16 +573,21 @@ public class ArrayList<T> implements Lis
     }
 
     private static void verifyIndexBounds(int index, int start, int end) {
+        if (end < start) {
+            throw new IllegalArgumentException("end (" + end + ") < " + "start (" + start + ")");
+        }
         if (index < start || index > end) {
             throw new IndexOutOfBoundsException("index " + index + " out of bounds [" + start + "," + end + "].");
         }
     }
 
     private static void verifyIndexBounds(int index, int count, int start, int end) {
-        if (count < 0) {
-            throw new IllegalArgumentException("count < 0, " + count);
+        if (end < start) {
+            throw new IllegalArgumentException("end (" + end + ") < " + "start (" + start + ")");
+        }
+        if (count < 0 || start < 0) {
+            throw new IllegalArgumentException("count (" + count + ") < 0 or start (" + start + ") < 0");
         }
-
         if (index < start) {
             throw new IndexOutOfBoundsException("index " + index + " out of bounds [" + start + "," + end + "].");
         }

Modified: pivot/trunk/core/src/org/apache/pivot/collections/LinkedList.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/LinkedList.java?rev=1324665&r1=1324664&r2=1324665&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/collections/LinkedList.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/collections/LinkedList.java Wed Apr 11 09:24:22 2012
@@ -657,14 +657,20 @@ public class LinkedList<T> implements Li
     }
 
     private static void verifyIndexBounds(int index, int start, int end) {
+        if (end < start) {
+            throw new IllegalArgumentException("end (" + end + ") < " + "start (" + start + ")");
+        }
         if (index < start || index > end) {
             throw new IndexOutOfBoundsException("index " + index + " out of bounds.");
         }
     }
 
     private static void verifyIndexBounds(int index, int count, int start, int end) {
-        if (count < 0) {
-            throw new IllegalArgumentException();
+        if (end < start) {
+            throw new IllegalArgumentException("end (" + end + ") < " + "start (" + start + ")");
+        }
+        if (count < 0 || start < 0) {
+            throw new IllegalArgumentException("count (" + count + ") < 0 or start (" + start + ") < 0");
         }
         if (index < start) {
             throw new IndexOutOfBoundsException("index " + index + " out of bounds.");