Bug 37383 - [PATCH]ClassCastException in MemValueIndexer
Summary: [PATCH]ClassCastException in MemValueIndexer
Status: CLOSED FIXED
Alias: None
Product: Xindice
Classification: Unclassified
Component: DB Engine (show other bugs)
Version: cvs head (1.1)
Hardware: All All
: P4 normal
Target Milestone: ---
Assignee: Xindice Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-07 14:19 UTC by Terry Rosenbaum
Modified: 2005-12-15 14:12 UTC (History)
0 users



Attachments
Patch for MemValueIndexer.java (2.53 KB, text/plain)
2005-11-07 14:22 UTC, Terry Rosenbaum
Details

Note You need to log in before you can comment on or make changes to this bug.
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!