SOLR-2564: Fixed ArrayIndexOutOfBoundsException when using simple format

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1145173 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Martijn van Groningen 2011-07-11 13:44:42 +00:00
parent 0d63bce7fe
commit 8445d20f5d
2 changed files with 16 additions and 1 deletions

View File

@ -585,7 +585,7 @@ public class Grouping {
}
}
int len = Math.min(numGroups, docsGathered);
int len = docsGathered - offset;
if (offset > len) {
len = 0;
}

View File

@ -182,7 +182,22 @@ public class TestGroupingSearch extends SolrTestCaseJ4 {
);
}
@Test
public void testGroupingSimpleFormatArrayIndexOutOfBoundsException() throws Exception {
assertU(add(doc("id", "1")));
assertU(add(doc("id", "2")));
assertU(add(doc("id", "3")));
assertU(commit());
assertJQ(
req("q", "*:*", "start", "1", "group", "true", "group.field", "id", "group.main", "true"),
"/response=={'numFound':3,'start':1,'docs':[{'id':'2'},{'id':'3'}]}"
);
assertJQ(
req("q", "*:*", "start", "1", "rows", "1", "group", "true", "group.field", "id", "group.main", "true"),
"/response=={'numFound':3,'start':1,'docs':[{'id':'2'}]}"
);
}
static String f = "foo_i";
static String f2 = "foo2_i";