diff --git a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java index 61e4bed5c1c..9114f3d7fa9 100644 --- a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java +++ b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java @@ -2699,7 +2699,9 @@ public class CollapsingQParserPlugin extends QParserPlugin { */ public void setGroupValues(int collapseKey, int contextDoc) throws IOException { assert 0 <= collapseKey : "negative collapseKey"; - assert collapseKey < groupHeadValues.length : "collapseKey too big -- need to grow array?"; + if (collapseKey >= groupHeadValues.length) { + grow(collapseKey + 1); + } setGroupValues(getOrInitGroupHeadValues(collapseKey), contextDoc); } @@ -2733,7 +2735,9 @@ public class CollapsingQParserPlugin extends QParserPlugin { */ public boolean testAndSetGroupValues(int collapseKey, int contextDoc) throws IOException { assert 0 <= collapseKey : "negative collapseKey"; - assert collapseKey < groupHeadValues.length : "collapseKey too big -- need to grow array?"; + if (collapseKey >= groupHeadValues.length) { + grow(collapseKey + 1); + } return testAndSetGroupValues(getOrInitGroupHeadValues(collapseKey), contextDoc); }