diff --git a/modules/grouping/src/java/org/apache/lucene/search/grouping/FirstPassGroupingCollector.java b/modules/grouping/src/java/org/apache/lucene/search/grouping/FirstPassGroupingCollector.java index 1b2718980aa..a1cf29410f2 100644 --- a/modules/grouping/src/java/org/apache/lucene/search/grouping/FirstPassGroupingCollector.java +++ b/modules/grouping/src/java/org/apache/lucene/search/grouping/FirstPassGroupingCollector.java @@ -229,7 +229,9 @@ public class FirstPassGroupingCollector extends Collector { // We already tested that the document is competitive, so replace // the bottom group with this new group. - final CollectedSearchGroup bottomGroup = orderedGroups.pollLast(); + // java 6-only: final CollectedSearchGroup bottomGroup = orderedGroups.pollLast(); + final CollectedSearchGroup bottomGroup = orderedGroups.last(); + orderedGroups.remove(bottomGroup); assert orderedGroups.size() == topNGroups -1; groupMap.remove(bottomGroup.groupValue);