LUCENE-2580: fix AIOOBE in MultiPhraseQuery

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@980909 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2010-07-30 18:23:13 +00:00
parent 53f74289d5
commit bea5529ed4
2 changed files with 22 additions and 1 deletions

View File

@ -457,6 +457,9 @@ Bug fixes
* LUCENE-2537: FSDirectory.copy() implementation was unsafe and could result in
OOM if a large file was copied. (Shai Erera)
* LUCENE-2580: MultiPhraseQuery throws AIOOBE if number of positions
exceeds number of terms at one position (Jayendra Patil via Mike McCandless)
New features
* LUCENE-2128: Parallelized fetching document frequencies during weight

View File

@ -132,7 +132,25 @@ public class TestMultiPhraseQuery extends LuceneTestCase {
searcher.close();
reader.close();
indexStore.close();
}
// LUCENE-2580
public void testTall() throws IOException {
MockRAMDirectory indexStore = new MockRAMDirectory();
RandomIndexWriter writer = new RandomIndexWriter(newRandom(), indexStore);
add("blueberry chocolate pie", writer);
add("blueberry chocolate tart", writer);
IndexReader r = writer.getReader();
writer.close();
IndexSearcher searcher = new IndexSearcher(r);
MultiPhraseQuery q = new MultiPhraseQuery();
q.add(new Term("body", "blueberry"));
q.add(new Term("body", "chocolate"));
q.add(new Term[] {new Term("body", "pie"), new Term("body", "tart")});
assertEquals(2, searcher.search(q, 1).totalHits);
r.close();
indexStore.close();
}
private void add(String s, RandomIndexWriter writer) throws IOException {