aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1715157 - /aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java
Date Thu, 19 Nov 2015 11:02:55 GMT
Author: cschneider
Date: Thu Nov 19 11:02:55 2015
New Revision: 1715157

URL: http://svn.apache.org/viewvc?rev=1715157&view=rev
Log:
[ARIES-1454] Avoid NPE

Modified:
    aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java

Modified: aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java?rev=1715157&r1=1715156&r2=1715157&view=diff
==============================================================================
--- aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java
(original)
+++ aries/trunk/transaction/transaction-blueprint/src/main/java/org/apache/aries/transaction/TxInterceptorImpl.java
Thu Nov 19 11:02:55 2015
@@ -28,7 +28,6 @@ import javax.transaction.Transactional.T
 import org.apache.aries.blueprint.Interceptor;
 import org.osgi.service.blueprint.reflect.ComponentMetadata;
 import org.osgi.service.coordinator.Coordination;
-import org.osgi.service.coordinator.CoordinationException;
 import org.osgi.service.coordinator.Coordinator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -75,11 +74,7 @@ public class TxInterceptorImpl implement
         }
         LOGGER.debug("PostCallWithException for bean {}, method {}.", getCmId(cm), m.getName(),
ex);
         final TransactionToken token = (TransactionToken)preCallToken;
-        try {
-            token.getCoordination().end();
-        } catch (CoordinationException e){
-            LOGGER.debug(e.getMessage(), e);
-        }
+        safeEndCoordination(token);
         try {
             Transaction tran = token.getActiveTransaction();
             if (tran != null && isRollBackException(ex)) {
@@ -93,7 +88,6 @@ public class TxInterceptorImpl implement
         }
     }
 
-
     @Override
     public void postCallWithReturn(ComponentMetadata cm, Method m, Object returnType, Object
preCallToken)
         throws Exception {
@@ -106,7 +100,7 @@ public class TxInterceptorImpl implement
             throw new IllegalStateException("Expected a TransactionToken from preCall but
got " + preCallToken);
         }
         final TransactionToken token = (TransactionToken)preCallToken;
-        token.getCoordination().end();
+        safeEndCoordination(token);
         try {
             token.getTransactionAttribute().finish(tm, token);
         } catch (Exception e) {
@@ -117,6 +111,16 @@ public class TxInterceptorImpl implement
             throw rbe;
         }
     }
+
+    private void safeEndCoordination(final TransactionToken token) {
+        try {
+            if (token != null && token.getCoordination() != null) {
+                token.getCoordination().end();
+            }
+        } catch (Exception e){
+            LOGGER.debug(e.getMessage(), e);
+        }
+    }
     
     private static String getCmId(ComponentMetadata cm) {
         return cm == null ? null : cm.getId();



Mime
View raw message