You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2013/05/03 16:11:15 UTC

svn commit: r1478801 - /lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/CollectionUtil.java

Author: jpountz
Date: Fri May  3 14:11:14 2013
New Revision: 1478801

URL: http://svn.apache.org/r1478801
Log:
LUCENE-4946: Re-add the random-access checks that have been lost during refactoring.

Modified:
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/CollectionUtil.java

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/CollectionUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/CollectionUtil.java?rev=1478801&r1=1478800&r2=1478801&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/CollectionUtil.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/CollectionUtil.java Fri May  3 14:11:14 2013
@@ -42,6 +42,8 @@ public final class CollectionUtil {
 
     ListIntroSorter(List<T> list, Comparator<? super T> comp) {
       super();
+      if (!(list instanceof RandomAccess))
+        throw new IllegalArgumentException("CollectionUtil can only sort random access lists in-place.");
       this.list = list;
       this.comp = comp;
     }
@@ -77,6 +79,8 @@ public final class CollectionUtil {
     @SuppressWarnings("unchecked")
     ListTimSorter(List<T> list, Comparator<? super T> comp, int maxTempSlots) {
       super(maxTempSlots);
+      if (!(list instanceof RandomAccess))
+        throw new IllegalArgumentException("CollectionUtil can only sort random access lists in-place.");
       this.list = list;
       this.comp = comp;
       if (maxTempSlots > 0) {