LUCENE-3580: add check to AssertingIndexSearcher that scorers obey DISI contract before next/advance

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1203206 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2011-11-17 14:45:23 +00:00
parent 4597d97e68
commit 4548a5d3a3

View File

@ -76,7 +76,18 @@ public class AssertingIndexSearcher extends IndexSearcher {
@Override
public Scorer scorer(AtomicReaderContext context, boolean scoreDocsInOrder,
boolean topScorer, Bits acceptDocs) throws IOException {
return w.scorer(context, scoreDocsInOrder, topScorer, acceptDocs);
Scorer scorer = w.scorer(context, scoreDocsInOrder, topScorer, acceptDocs);
if (scorer != null) {
// check that scorer obeys disi contract for docID() before next()/advance
try {
int docid = scorer.docID();
assert docid == -1 || docid == DocIdSetIterator.NO_MORE_DOCS;
} catch (UnsupportedOperationException ignored) {
// from a top-level BS1
assert topScorer;
}
}
return scorer;
}
@Override