mirror of https://github.com/apache/lucene.git
throw IllegalArgumentException for nDocs <= 0 to avoid NullPointerException
PR: 32227 Submitted by: Paul Elschot git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150641 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bcfcf9eeb7
commit
ffc746e3d0
|
@ -83,6 +83,10 @@ public class IndexSearcher extends Searcher {
|
|||
// inherit javadoc
|
||||
public TopDocs search(Query query, Filter filter, final int nDocs)
|
||||
throws IOException {
|
||||
|
||||
if (nDocs <= 0) // null might be returned from hq.top() below.
|
||||
throw new IllegalArgumentException("nDocs must be > 0");
|
||||
|
||||
Scorer scorer = query.weight(this).scorer(reader);
|
||||
if (scorer == null)
|
||||
return new TopDocs(0, new ScoreDoc[0]);
|
||||
|
|
Loading…
Reference in New Issue