From: AW (JIRA) <ji...@co...> - 2012-03-01 07:41:13
|
AW created GEOT-4053: ------------------------ Summary: JDBCFeatureStore.removeFeatures does not close to the database connection it opened Key: GEOT-4053 URL: https://jira.codehaus.org/browse/GEOT-4053 Project: GeoTools Issue Type: Bug Components: jdbc Affects Versions: 2.7.4 Reporter: AW In JDBCFeatureStore.removeFeatures a connection is opened and is not closed at the end, so the connection pool will run out of connections eventually. Testcase: DBCPDataSource ds = (DBCPDataSource)((JDBCDataStore)getStore()).getDataSource(); Field wrappedField = AbstractManageableDataSource.class.getDeclaredField( "wrapped" ); wrappedField.setAccessible( true ); BasicDataSource wds = (BasicDataSource)wrappedField.get( ds ); System.out.println( "active conncetions (before): " + wds.getNumActive() ); JDBCFeatureStore featureStore = (JDBCFeatureStore)getFields(); featureStore.removeFeatures(getURLFilter(uri)); System.out.println( "active connections (after): " + wds.getNumActive() ); Output: active conncetions (before): 0 Feb 29, 2012 9:32:25 AM org.geotools.jdbc.JDBCDataStore createConnection FINE: CREATE CONNECTION Feb 29, 2012 9:32:25 AM org.geotools.jdbc.JDBCDataStore ensureAuthorization FINE: SELECT "id","uri",encode(ST_AsBinary(ST_Force_2D("geom")),'base64') as "geom" FROM "geoserver"."fields" WHERE "uri" = 'http://127.0.0.1:38080/resource/area/PFD141_area_158' Feb 29, 2012 9:32:25 AM org.geotools.jdbc.JDBCDataStore createConnection FINE: CREATE CONNECTION Feb 29, 2012 9:32:25 AM org.geotools.jdbc.JDBCDataStore getBounds FINE: Retriving bounding box: SELECT ST_AsText(ST_Force_2D(ST_Envelope(ST_Extent("geom"::geometry)))) FROM "geoserver"."fields" WHERE "uri" = 'http://127.0.0.1:38080/resource/area/PFD141_area_158' Feb 29, 2012 9:32:25 AM org.geotools.jdbc.JDBCDataStore closeSafe FINE: CLOSE CONNECTION Feb 29, 2012 9:32:25 AM org.geotools.jdbc.JDBCDataStore delete FINE: Removing feature(s): DELETE FROM "geoserver"."fields" WHERE "uri" = 'http://127.0.0.1:38080/resource/area/PFD141_area_158' active connections (after): 1 -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira |