deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject deltaspike git commit: DELTASPIKE-975 fixed cleanup of dependent-scoped EntityManagerResolver
Date Wed, 05 Aug 2015 15:43:43 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 5895eb73b -> f7c0f1b3f


DELTASPIKE-975 fixed cleanup of dependent-scoped EntityManagerResolver


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/f7c0f1b3
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/f7c0f1b3
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/f7c0f1b3

Branch: refs/heads/master
Commit: f7c0f1b3f9ea21ecc341818151903983387c8147
Parents: 5895eb7
Author: gpetracek <gpetracek@apache.org>
Authored: Wed Aug 5 17:38:20 2015 +0200
Committer: gpetracek <gpetracek@apache.org>
Committed: Wed Aug 5 17:42:29 2015 +0200

----------------------------------------------------------------------
 .../data/impl/handler/EntityManagerLookup.java          | 12 +++++++++++-
 .../deltaspike/data/impl/handler/QueryHandler.java      |  1 +
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/f7c0f1b3/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityManagerLookup.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityManagerLookup.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityManagerLookup.java
index 4554497..3a78393 100644
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityManagerLookup.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/EntityManagerLookup.java
@@ -36,6 +36,8 @@ public class EntityManagerLookup
     @Any
     private Instance<EntityManager> entityManager;
 
+    private DependentProvider<? extends EntityManagerResolver> dependentResolverProvider;
+
     public EntityManager lookupFor(final RepositoryComponent repository)
     {
         EntityManager result = null;
@@ -45,8 +47,8 @@ public class EntityManagerLookup
             if (!repository.isEntityManagerResolverIsNormalScope())
             {
                 final DependentProvider<? extends EntityManagerResolver> resolver =
lookupResolver(emrc);
+                dependentResolverProvider = resolver;
                 result = resolver.get().resolveEntityManager();
-                resolver.destroy();
             }
             else
             {
@@ -64,6 +66,14 @@ public class EntityManagerLookup
         return result;
     }
 
+    public void release()
+    {
+        if (dependentResolverProvider != null)
+        {
+            dependentResolverProvider.destroy();
+        }
+    }
+
     private DependentProvider<? extends EntityManagerResolver> lookupResolver(
             Class<? extends EntityManagerResolver> resolverClass)
     {

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/f7c0f1b3/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/QueryHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/QueryHandler.java
b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/QueryHandler.java
index 6b6ddb5..0501a4f 100755
--- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/QueryHandler.java
+++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/handler/QueryHandler.java
@@ -94,6 +94,7 @@ public class QueryHandler implements Serializable, InvocationHandler
         }
         finally
         {
+            entityManagerLookup.release();
             context.dispose();
         }
     }


Mime
View raw message