[ 
https://issues.apache.org/jira/browse/LUCENE-3939?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13243294#comment-13243294
 ] 

Michael McCandless commented on LUCENE-3939:
--------------------------------------------

OK I see this ClassCastException:

{noformat}
    [junit] Testcase: 
testMisUse(org.apache.lucene.index.TestTermVectorsReader):        Caused an 
ERROR
    [junit] org.apache.lucene.index.TermVectorEntry cannot be cast to 
java.lang.Comparable
    [junit] java.lang.ClassCastException: 
org.apache.lucene.index.TermVectorEntry cannot be cast to java.lang.Comparable
    [junit]     at java.util.TreeMap.put(TreeMap.java:542)
    [junit]     at java.util.TreeSet.add(TreeSet.java:238)
    [junit]     at 
org.apache.lucene.index.SortedTermVectorMapper.map(SortedTermVectorMapper.java:71)
    [junit]     at 
org.apache.lucene.index.TestTermVectorsReader.testMisUse(TestTermVectorsReader.java:456)
    [junit]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [junit]     at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [junit]     at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [junit]     at java.lang.reflect.Method.invoke(Method.java:597)
    [junit]     at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    [junit]     at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    [junit]     at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    [junit]     at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    [junit]     at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    [junit]     at 
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    [junit]     at 
org.apache.lucene.util.LuceneTestCase$SubclassSetupTeardownRule$1.evaluate(LuceneTestCase.java:630)
    [junit]     at 
org.apache.lucene.util.LuceneTestCase$InternalSetupTeardownRule$1.evaluate(LuceneTestCase.java:536)
    [junit]     at 
org.apache.lucene.util.SystemPropertiesInvariantRule$1.evaluate(SystemPropertiesInvariantRule.java:67)
    [junit]     at 
org.apache.lucene.util.LuceneTestCase$TestResultInterceptorRule$1.evaluate(LuceneTestCase.java:457)
    [junit]     at 
org.apache.lucene.util.UncaughtExceptionsRule$1.evaluate(UncaughtExceptionsRule.java:74)
    [junit]     at 
org.apache.lucene.util.LuceneTestCase$SaveThreadAndTestNameRule$1.evaluate(LuceneTestCase.java:508)
    [junit]     at org.junit.rules.RunRules.evaluate(RunRules.java:18)
    [junit]     at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    [junit]     at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    [junit]     at 
org.apache.lucene.util.LuceneTestCaseRunner.runChild(LuceneTestCaseRunner.java:146)
    [junit]     at 
org.apache.lucene.util.LuceneTestCaseRunner.runChild(LuceneTestCaseRunner.java:50)
    [junit]     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    [junit]     at 
org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    [junit]     at 
org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    [junit]     at 
org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    [junit]     at 
org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    [junit]     at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    [junit]     at 
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    [junit]     at 
org.apache.lucene.util.UncaughtExceptionsRule$1.evaluate(UncaughtExceptionsRule.java:74)
    [junit]     at 
org.apache.lucene.util.StoreClassNameRule$1.evaluate(StoreClassNameRule.java:36)
    [junit]     at 
org.apache.lucene.util.SystemPropertiesInvariantRule$1.evaluate(SystemPropertiesInvariantRule.java:67)
    [junit]     at org.junit.rules.RunRules.evaluate(RunRules.java:18)
    [junit]     at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    [junit]     at 
junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:39)
    [junit]     at 
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:518)
    [junit]     at 
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1052)
    [junit]     at 
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:906)
{noformat}

However, I think it's because you're passing null as the 
Comparator<TermVectorEntry> to SortedTermVectorMapper, forcing the TreeSet to 
try to cast the TermVectorEntry to Comparable, which then fails.

Really you should not pass a null Comparator...
                
> ClassCastException thrown in the map(String,int,TermVectorOffsetInfo[],int[]) 
> method in org.apache.lucene.index.SortedTermVectorMapper
> --------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3939
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3939
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: core/index
>    Affects Versions: 3.0.2, 3.1, 3.4, 3.5
>            Reporter: SHIN HWEI TAN
>   Original Estimate: 0.05h
>  Remaining Estimate: 0.05h
>
> 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);
>               ...
>       }
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to