Apache Lucene open-source search software
LUCENE-4946: Re-add the random-access checks that have been lost during refactoring.
Adrien Grand64dfbfdfb219
diff --git a/lucene/core/src/java/org/apache/lucene/util/CollectionUtil.java b/lucene/core/src/java/org/apache/lucene/util/CollectionUtil.javaindex c8aef094912..65d4b948868 100644--- a/lucene/core/src/java/org/apache/lucene/util/CollectionUtil.java+++ b/lucene/core/src/java/org/apache/lucene/util/CollectionUtil.java@@ -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) {