diff --git a/droid-results/src/main/java/uk/gov/nationalarchives/droid/profile/SpringProfileInstanceFactory.java b/droid-results/src/main/java/uk/gov/nationalarchives/droid/profile/SpringProfileInstanceFactory.java index 5c4e8c54f..6f2065720 100644 --- a/droid-results/src/main/java/uk/gov/nationalarchives/droid/profile/SpringProfileInstanceFactory.java +++ b/droid-results/src/main/java/uk/gov/nationalarchives/droid/profile/SpringProfileInstanceFactory.java @@ -53,7 +53,6 @@ * */ public class SpringProfileInstanceFactory implements ProfileInstanceLocator { - /** * */ @@ -63,7 +62,7 @@ public class SpringProfileInstanceFactory implements ProfileInstanceLocator { private final Logger log = LoggerFactory.getLogger(getClass()); - private Map profileInstanceManagers = + private final Map profileInstanceManagers = new HashMap(); /** @@ -159,6 +158,10 @@ public Connection getConnection(String profileId) { */ @Override public synchronized void closeProfileInstance(String location) { + ApplicationContext ac = profileInstanceManagers.get(location); + DerbyPooledDataSource dataSource = (DerbyPooledDataSource) ac + .getBean(DATA_SOURCE_BEAN_NAME); + dataSource.close(); GenericApplicationContext ctx = profileInstanceManagers .remove(location); if (ctx != null) {