Bug 37383

Summary: [PATCH]ClassCastException in MemValueIndexer
Product: Xindice Reporter: Terry Rosenbaum <Terry.Rosenbaum>
Component: DB EngineAssignee: Xindice Developers <xindice-dev>
Status: CLOSED FIXED    
Severity: normal    
Priority: P4    
Version: cvs head (1.1)   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Patch for MemValueIndexer.java

Description Terry Rosenbaum 2005-11-07 14:19:54 UTC
If you look at the code, it will be obvious.
A ClassCastException will occur when doing operations like:
aLocatorSet = (TreeSet) ((Map.Entry) aValueIterator.next()).getValue();

That is because the Iterator being used is from a Collection, not a map.
The change is to get the Iterator from the entrySet() of the TreeMap instead
of the values(). e.g.
aValueIterator = itsValues.entrySet().iterator();
instead of
aValueIterator = itsValues.values().iterator();

If you run the buggy version, everything appears OK (poor error handling) but
indexes are not used.

Patch for org.apache.xindice.core.indexer.MemValueIndexer is attached.
Comment 1 Terry Rosenbaum 2005-11-07 14:22:06 UTC
Created attachment 16892 [details]
Patch for MemValueIndexer.java

Fixed silent failure with ClassCastException. The MemValueIndexer did not work
as originally written but poor error handling caused tests to think everything
was OK.
Comment 2 Vadim Gritsenko 2005-12-15 23:12:36 UTC
Patch applied. Thanks!