lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dna...@apache.org
Subject cvs commit: jakarta-lucene/src/java/org/apache/lucene/search IndexSearcher.java
Date Sun, 14 Nov 2004 13:26:28 GMT
dnaber      2004/11/14 05:26:28

  Modified:    src/java/org/apache/lucene/search IndexSearcher.java
  Log:
  throw IllegalArgumentException for nDocs <= 0 to avoid NullPointerException
  
  PR: 32227
  Submitted by: Paul Elschot
  
  Revision  Changes    Path
  1.23      +4 -0      jakarta-lucene/src/java/org/apache/lucene/search/IndexSearcher.java
  
  Index: IndexSearcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/IndexSearcher.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- IndexSearcher.java	30 Sep 2004 20:53:07 -0000	1.22
  +++ IndexSearcher.java	14 Nov 2004 13:26:28 -0000	1.23
  @@ -83,6 +83,10 @@
     // 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]);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message