Jody Garnett ha scritto:
> Andrea we *do* ask that an Iterator get's closed when it falls off the
> end, but this does not
> protect us in the event of IO Error.
>
> It could be we have made a bad tradeoff, and should ask each iterator
> implementor to clean up everything as their throw an IOError (it force
> implementors to take on the "finally" pain once so all the client code
> does not have to).
>
> Defined as is the implementors were "easy" to write, getting rid of
> close( Iterator ) would swing the library more in favour of the user
> community would be a large QA task, added to the list of FilterVisitor,
> FeatureBuilder and FeatureTypeBuilder QA tasks already slowing us down.
I'd definitely like it to be me more user friendly. But in fact,
I think FeatureIterator is ok, it has a close method you can call if you
drop off the iteration earlier and does not break the iteration idiom:
for(FeatureIterator it = coll.features(); it.hasNext(); ) {
Feature f = it.next();
if(myFilter.evaluate(f)) {
// some code
it.close();
break;
}
}
and... oh, you're right, in case of exception the iterator is not closed.
Having FeatureCollection extending collection is worse too, since
a simple Iterator does not have a close method. And, it gets worse
too. Think someone calling
Collections.min(featureCollection, comparator),
or someone doing "new ArrayList(featureCollection)": those operations
will open up an interator internally, and you don't have any control
against it (some generic algorithm may indeed decide to drop iteration
before end and you can't do anything about it!!!).
So I guess I'd like to ask that:
* every feature iterator returned is able to close itself once
iteration ends, and before every exception is thrown (its state should
be badly compromised and beyond repair, no?);
* avoid having FeatureCollection implement
Collection... if we cannot trust a generic collection based algorithm
to work against our collection, we should not allow it to, no?
Cheers
Andrea
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel