Author: aaime
Date: 2009-10-26 06:20:19 -0400 (Mon, 26 Oct 2009)
New Revision: 34251
Modified:
branches/2.5.x/modules/library/data/
branches/2.5.x/modules/library/data/src/main/java/org/geotools/data/store/ContentFeatureCollection.java
Log:
GEOT-2803, ContentFeatureCollection is leaking listeners
Property changes on: branches/2.5.x/modules/library/data
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/modules/library/data:33392,33591-33592,33656,34075
+ /trunk/modules/library:34249
/trunk/modules/library/data:33392,33591-33592,33656,34075,34249
Modified: branches/2.5.x/modules/library/data/src/main/java/org/geotools/data/store/ContentFeatureCollection.java
===================================================================
--- branches/2.5.x/modules/library/data/src/main/java/org/geotools/data/store/ContentFeatureCollection.java 2009-10-26 10:13:47 UTC (rev 34250)
+++ branches/2.5.x/modules/library/data/src/main/java/org/geotools/data/store/ContentFeatureCollection.java 2009-10-26 10:20:19 UTC (rev 34251)
@@ -109,9 +109,6 @@
this.featureSource = featureSource;
this.query = query;
- //add the feautre source listener
- featureSource.addFeatureListener(listener);
-
//retype feature type if necessary
if ( query.getPropertyNames() != Query.ALL_NAMES ) {
this.featureType =
@@ -170,7 +167,14 @@
* @param listener The listener to add
*/
public void addListener(CollectionListener listener) {
- listeners.add(listener);
+ // create the bridge only if we have collection listeners around
+ synchronized (listeners) {
+ if(listeners.size() == 0) {
+ featureSource.addFeatureListener(this.listener);
+ }
+
+ listeners.add(listener);
+ }
}
/**
@@ -179,7 +183,13 @@
* @param listener The listener to remove
*/
public void removeListener(CollectionListener listener) {
- listeners.remove(listener);
+ // as soon as the listeners are out we clean up
+ synchronized (listeners) {
+ listeners.remove(listener);
+
+ if(listeners.size() == 0)
+ featureSource.removeFeatureListener(this.listener);
+ }
}
// Iterators
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference_______________________________________________
GeoTools-commits mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-commits