You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2015/11/18 21:20:50 UTC

tomee git commit: TOMEE-1663 properly destroying resources: lazy one are unwrapped if created and resource adapters are really destroyed last (needed unwrapping)

Repository: tomee
Updated Branches:
  refs/heads/master 3069db0ba -> dd28c89b2


TOMEE-1663 properly destroying resources: lazy one are unwrapped if created and resource adapters are really destroyed last (needed unwrapping)


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

Branch: refs/heads/master
Commit: dd28c89b2005b952a97a650c041db6018fd4545f
Parents: 3069db0
Author: Romain Manni-Bucau <rm...@gmail.com>
Authored: Wed Nov 18 12:20:42 2015 -0800
Committer: Romain Manni-Bucau <rm...@gmail.com>
Committed: Wed Nov 18 12:20:42 2015 -0800

----------------------------------------------------------------------
 .../openejb/assembler/classic/Assembler.java    | 22 +++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/dd28c89b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index 39b3896..69149ef 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -1833,10 +1833,19 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
         Collections.sort(resources, new Comparator<DestroyingResource>() { // end by destroying RA after having closed CF pool (for jms for instanceà
             @Override
             public int compare(final DestroyingResource o1, final DestroyingResource o2) {
-                if (ResourceAdapter.class.isInstance(o2.instance) && !ResourceAdapter.class.isInstance(o1.instance)) {
+                boolean ra1 = isRa(o1.instance);
+                boolean ra2 = isRa(o1.instance);
+                if (ra2 && !ra1) {
                     return -1;
                 }
-                return 1;
+                if (ra1 && !ra2) {
+                    return 1;
+                }
+                return o1.name.compareTo(o2.name);
+            }
+
+            private boolean isRa(final Object instance) {
+                return ResourceAdapter.class.isInstance(instance) || ResourceAdapterReference.class.isInstance(instance);
             }
         });
 
@@ -1851,7 +1860,14 @@ public class Assembler extends AssemblerTool implements org.apache.openejb.spi.A
         return resources;
     }
 
-    private void destroyResource(final String name, final String className, final Object object) {
+    private void destroyResource(final String name, final String className, final Object inObject) {
+        Object object;
+        try {
+            object = LazyResource.class.isInstance(inObject) && LazyResource.class.cast(inObject).isInitialized() ?
+                LazyResource.class.cast(inObject).getObject() : inObject;
+        } catch (final NamingException e) {
+            object = inObject; // in case it impl DestroyableResource
+        }
 
         Collection<Method> preDestroy = null;