From 29986c43338d9fa35b93cf29d3c9bc8357ad0578 Mon Sep 17 00:00:00 2001 From: sparkhi Date: Wed, 17 Jan 2024 15:45:36 +0000 Subject: [PATCH] closing the profile database when profile closes --- .../droid/profile/SpringProfileInstanceFactory.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) {