NPE raised from SubFeatureList when sorting
-------------------------------------------

                 Key: GEOT-3244
                 URL: http://jira.codehaus.org/browse/GEOT-3244
             Project: GeoTools
          Issue Type: Bug
          Components: data
    Affects Versions: 2.6.5
         Environment: Linux Fedora 12, JDK 1.6.0_17
            Reporter: Luca Morandini
         Attachments: SubFeatureListTest.java

I wanted to sort a FeatureCollection, hence I wrote something like:

FilterFactory filterFactory = CommonFactoryFinder
.getFilterFactory(null);

SortByImpl sort = (SortByImpl) filterFactory.sort(
BulletinIngestor.NAMECOLUMN, SortOrder.ASCENDING);

SubFeatureList outList = new SubFeatureList(outColl, sort);

Iterator<SimpleFeature> featIter = (Iterator<SimpleFeature>) outList
.openIterator();

But the last line gave me an NPE:
java.lang.NullPointerException
        at 
org.geotools.feature.collection.SubFeatureList.getFeatureMember(SubFeatureList.java:241)
        at 
org.geotools.feature.collection.SubFeatureList$1.compare(SubFeatureList.java:149)
        at 
org.geotools.feature.collection.SubFeatureList$1.compare(SubFeatureList.java:147)
...

I investigated a bit, and it turned out that openIterator() eventually called 
createIndex(), which in turn called getFeatureMember(), which relies on the 
index 
member variable, which is created by createIndex() !

So, unless I got it wrong, I presume there is something flawed in 
SubFeatureList, 
since it relies on the sorted List to produce the sorted List instead on 
relying 
the un-sorted Collection.

I solved the issue by subclassing SubFeatureList and overriding 
getFeatureMember.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to