tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1141140 - /openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java
Date Wed, 29 Jun 2011 15:53:14 GMT
Author: xuhaihong
Date: Wed Jun 29 15:53:13 2011
New Revision: 1141140

URL: http://svn.apache.org/viewvc?rev=1141140&view=rev
Log:
OPENEJB-1621 ThreadContext is not exited correctly in MdbContainer.release method

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java?rev=1141140&r1=1141139&r2=1141140&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/mdb/MdbContainer.java
Wed Jun 29 15:53:13 2011
@@ -451,26 +451,31 @@ public class MdbContainer implements Rpc
     public void release(BeanContext deployInfo, Object instance) {
         // get the mdb call context
         ThreadContext callContext = ThreadContext.getThreadContext();
+        boolean contextExitRequired = false;
         if (callContext == null) {
             callContext = new ThreadContext(deployInfo, null);
             ThreadContext.enter(callContext);
+            contextExitRequired = true;
 
         }
-
-        // if we have an mdb call context we need to invoke the after invoke method
-        MdbCallContext mdbCallContext = callContext.get(MdbCallContext.class);
-        if (mdbCallContext != null) {
-            try {
-                afterInvoke(mdbCallContext.txPolicy, callContext);
-            } catch (Exception e) {
-                logger.error("error while releasing message endpoint", e);
-            } finally {
-                EndpointFactory endpointFactory = (EndpointFactory) deployInfo.getContainerData();
-                endpointFactory.getInstanceFactory().freeInstance((Instance)instance, false);
-                ThreadContext.exit(mdbCallContext.oldCallContext);
+        try {
+            // if we have an mdb call context we need to invoke the after invoke method
+            MdbCallContext mdbCallContext = callContext.get(MdbCallContext.class);
+            if (mdbCallContext != null) {
+                try {
+                    afterInvoke(mdbCallContext.txPolicy, callContext);
+                } catch (Exception e) {
+                    logger.error("error while releasing message endpoint", e);
+                } finally {
+                    EndpointFactory endpointFactory = (EndpointFactory) deployInfo.getContainerData();
+                    endpointFactory.getInstanceFactory().freeInstance((Instance) instance,
false);
+                }
+            }
+        } finally {
+            if (contextExitRequired) {
+                ThreadContext.exit(callContext);
             }
         }
-
     }
 
     private static class MdbCallContext {



Mime
View raw message