apache / apache/lucene

TermOrdsIterator#lookup throws ArrayIndexOutOfBoundsException [LUCENE-3377]

Open
#4,450 2 comments 0 reactions 0 assignees View on GitHub
affects-version:4.0-ALPHA legacy-jira-priority:Minor type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

TermOrdsIterator's lookup method can throw an ArrayIndexOutOfBoundsException if reuse argument is reused acros segments.

Example collector:

```Java
private DocTermOrds.TermOrdsIterator reuse = null;

public void collect(int doc) throws IOException {
...
reuse = docTermOrds.lookup(doc, reuse);
...
}

public void setNextReader(IndexReader.AtomicReaderContext context) throws IOException {
docTermOrds = FieldCache.DEFAULT.getDocTermOrds(context.reader, field);
....
}
```

If reuse argument is always null exception doesn't occur.

---
Migrated from [LUCENE-3377](https://issues.apache.org/jira/browse/LUCENE-3377) by Martijn van Groningen (@martijnvg), updated Aug 17 2011

Contributor guide

Open the contributing guide

Research direction

Start at DocTermOrds.TermOrdsIterator#lookup and inspect the collector example, especially reuse across IndexReader segments in setNextReader. Reproduce the failure with a reused iterator and verify that the example no longer throws ArrayIndexOutOfBoundsException; the issue does not name a specific test or file.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.