This is an automated email from the git hooks/post-receive script. New commit to branch feature/connectionproviderclosingleak in repository topia-2.x. See https://gitlab.nuiton.org/nuiton/topia-2.x.git commit 17beaa16e50532e5432f5359e6db4d5af7435c24 Author: Eric Chatellier <eric.chatellier@gmail.com> Date: Wed Sep 13 23:07:54 2017 +0200 Fix connection provider closing --- .../org/nuiton/topia/framework/TopiaContextImpl.java | 20 ++++++++++++++------ .../java/org/nuiton/topia/framework/TopiaUtil.java | 7 ++++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java b/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java index 191fbf18..bd9bfbd0 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java @@ -838,13 +838,21 @@ public class TopiaContextImpl implements TopiaContextImplementor { hibernate.close(); getParentContext().removeChildContext(this); } else { - if (hibernateFactory != null) { - // XXX AThimel 03/04/14 This is just a security, I'm not sure it is useful anymore - // close connection provider if possible (http://nuiton.org/issues/2757) - ConnectionProvider service = TopiaUtil.getHibernateService(hibernateFactory, ConnectionProvider.class); - if (service != null && service instanceof Stoppable) { - Stoppable stoppable = (Stoppable) service; + // XXX AThimel 03/04/14 This is just a security, I'm not sure it is useful anymore + // close connection provider if possible (http://nuiton.org/issues/2757) + ServiceRegistry serviceRegistry = getServiceRegistry(); + ConnectionProvider service = serviceRegistry.getService(ConnectionProvider.class); + if (service != null && service instanceof Stoppable) { + Stoppable stoppable = (Stoppable) service; + stoppable.stop(); + } + + if (hibernateFactory != null) { + + ConnectionProvider service2 = TopiaUtil.getHibernateService(hibernateFactory, ConnectionProvider.class); + if (service2 != null && service2 instanceof Stoppable) { + Stoppable stoppable = (Stoppable) service2; stoppable.stop(); } diff --git a/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaUtil.java b/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaUtil.java index 34ebdfdb..c35d3c87 100644 --- a/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaUtil.java +++ b/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaUtil.java @@ -56,6 +56,7 @@ import org.hibernate.service.Service; import org.hibernate.service.ServiceRegistry; import org.hibernate.service.spi.ServiceRegistryImplementor; import org.hibernate.service.spi.SessionFactoryServiceRegistry; +import org.hibernate.service.spi.Stoppable; import org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl; import org.hibernate.tool.schema.extract.spi.DatabaseInformation; import org.hibernate.tool.schema.extract.spi.TableInformation; @@ -74,6 +75,7 @@ import org.nuiton.util.RecursiveProperties; import org.nuiton.util.Resource; import com.google.common.base.Supplier; +import com.google.common.util.concurrent.Runnables; /** * TODO-fdesbois-20100507 : Need javadoc + translations for existing methods. @@ -482,7 +484,10 @@ public class TopiaUtil { @Override public void close() throws IOException { // Do not close the SessionFactory, it is probably used somewhere else - + if (connectionProvider != null && connectionProvider instanceof Stoppable) { + Stoppable connectionProviderStoppable = (Stoppable)connectionProvider; + connectionProviderStoppable.stop(); + } // On the over hand, if standardServiceRegistry is provided, that means the its has been created explicitly // for the current instance, close it if (standardServiceRegistry != null && embeddedRegistry) { -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.