jpountz commented on a change in pull request #769: LUCENE-8905: Better Error Handling For Illegal Arguments URL: https://github.com/apache/lucene-solr/pull/769#discussion_r307654649
########## File path: lucene/core/src/java/org/apache/lucene/search/TopDocsCollector.java ########## @@ -136,14 +136,21 @@ public TopDocs topDocs(int start, int howMany) { // pq.size() or totalHits. int size = topDocsSize(); - // Don't bother to throw an exception, just return an empty TopDocs in case - // the parameters are invalid or out of range. - // TODO: shouldn't we throw IAE if apps give bad params here so they dont - // have sneaky silent bugs? - if (start < 0 || start >= size || howMany <= 0) { + + if (start < 0 || start > size) { Review comment: I don't think we should validate `start` against `size` since `size` depends on the number of matches, and callers have no clue about its value at this point? Otherwise we are making this method almost impossible to use? The thing that we should validate is that `start + howMany` is less than or equal to the `numHits` parameter (which doesn't seem to be passed to TopDocsCollector by its sub classes at the moment, but we could)? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org