Prevent limit of search outbounding max int value

The problem occurs when IndexConfig is created with the
default value, i.e., Integer.MAX_VALUE, and the start
value in the QueryOptions instance is greater than 0.

Bug: Issue 4006
Change-Id: Ib746a7941505a10e0c5a2b1d0a3ca79fca11de5f
This commit is contained in:
Hongkai Liu
2016-08-31 11:21:22 -04:00
parent 57367a17df
commit 3d2e738991

View File

@@ -447,6 +447,9 @@ public class LuceneChangeIndex implements ChangeIndex {
IndexSearcher[] searchers = new IndexSearcher[indexes.size()];
try {
int realLimit = opts.start() + opts.limit();
if (Integer.MAX_VALUE - opts.limit() < opts.start()) {
realLimit = Integer.MAX_VALUE;
}
TopFieldDocs[] hits = new TopFieldDocs[indexes.size()];
for (int i = 0; i < indexes.size(); i++) {
searchers[i] = indexes.get(i).acquire();