ClassCastException thrown in the map(String,int,TermVectorOffsetInfo[],int[]) method in org.apache.lucene.index.SortedTermVectorMapper [LUCENE-3939]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
The method "map" in the "SortedTermVectorMapper" class does not check the parameter "term" for the valid values. It throws ClassCastException when called with a invalid string for the parameter "term" (i.e., "var3.map("\*", (-1), null, null)"). The exception thrown is due to an explict cast(i.e., casting the return value of termToTVE.get(term) to type "TermVectorEntry").
Suggested Fixes: Replace the beginning of the method body for the class "SortedTermVectorMapper" by changing it like this:
public void map(String term, int frequency, TermVectorOffsetInfo[] offsets, int[] positions) {
if(termToTVE.get(term) instanceof TermVectorEntry){
TermVectorEntry entry = (TermVectorEntry) termToTVE.get(term);
...
}
}
---
Migrated from [LUCENE-3939](https://issues.apache.org/jira/browse/LUCENE-3939) by SHIN HWEI TAN, updated Apr 02 2012
Contributor guide
Assessment
This issue has not been assessed yet.