tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgallim...@apache.org
Subject tomee git commit: TOMEE-2257 fix test
Date Wed, 10 Oct 2018 16:24:49 GMT
Repository: tomee
Updated Branches:
  refs/heads/master 5b295078f -> be9f45e6e


TOMEE-2257 fix test


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

Branch: refs/heads/master
Commit: be9f45e6ee96e8155d50fa3cdac13fd2a7cf7422
Parents: 5b29507
Author: Jonathan Gallimore <jon@jrg.me.uk>
Authored: Wed Oct 10 17:22:52 2018 +0100
Committer: Jonathan Gallimore <jon@jrg.me.uk>
Committed: Wed Oct 10 17:24:33 2018 +0100

----------------------------------------------------------------------
 .../openejb/resource/AutoConnectionTracker.java | 72 ++++++++++----------
 1 file changed, 37 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/be9f45e6/container/openejb-core/src/main/java/org/apache/openejb/resource/AutoConnectionTracker.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/resource/AutoConnectionTracker.java
b/container/openejb-core/src/main/java/org/apache/openejb/resource/AutoConnectionTracker.java
index cd78a93..49f891e 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/resource/AutoConnectionTracker.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/resource/AutoConnectionTracker.java
@@ -104,51 +104,53 @@ public class AutoConnectionTracker implements ConnectionTracker {
      * @param reassociate    should always be false
      */
     public void handleObtained(final ConnectionTrackingInterceptor interceptor, final ConnectionInfo
connectionInfo, final boolean reassociate) throws ResourceException {
-        Transaction currentTx = null;
-        try {
-            currentTx = txMgr.getTransaction();
-        } catch (SystemException e) {
-            //ignore
-        }
-
-        if (currentTx != null) {
-            Map<ManagedConnectionInfo, Map<ConnectionInfo, Object>> txConnections
= (Map<ManagedConnectionInfo, Map<ConnectionInfo, Object>>) registry.getResource(KEY);
-            if (txConnections == null) {
-                txConnections = new HashMap<ManagedConnectionInfo, Map<ConnectionInfo,
Object>>();
-                registry.putResource(KEY, txConnections);
+        if (txMgr != null && registry != null) {
+            Transaction currentTx = null;
+            try {
+                currentTx = txMgr.getTransaction();
+            } catch (SystemException e) {
+                //ignore
             }
 
-            Map<ConnectionInfo, Object> connectionObjects = txConnections.get(connectionInfo.getManagedConnectionInfo());
-            if (connectionObjects == null) {
-                connectionObjects = new HashMap<ConnectionInfo, Object>();
-                txConnections.put(connectionInfo.getManagedConnectionInfo(), connectionObjects);
-            }
+            if (currentTx != null) {
+                Map<ManagedConnectionInfo, Map<ConnectionInfo, Object>> txConnections
= (Map<ManagedConnectionInfo, Map<ConnectionInfo, Object>>) registry.getResource(KEY);
+                if (txConnections == null) {
+                    txConnections = new HashMap<ManagedConnectionInfo, Map<ConnectionInfo,
Object>>();
+                    registry.putResource(KEY, txConnections);
+                }
 
-            connectionObjects.put(connectionInfo, connectionInfo.getConnectionProxy());
+                Map<ConnectionInfo, Object> connectionObjects = txConnections.get(connectionInfo.getManagedConnectionInfo());
+                if (connectionObjects == null) {
+                    connectionObjects = new HashMap<ConnectionInfo, Object>();
+                    txConnections.put(connectionInfo.getManagedConnectionInfo(), connectionObjects);
+                }
 
-            registry.registerInterposedSynchronization(new Synchronization() {
-                @Override
-                public void beforeCompletion() {
-                    final Map<ManagedConnectionInfo, Map<ConnectionInfo, Object>>
txConnections = (Map<ManagedConnectionInfo, Map<ConnectionInfo, Object>>) registry.getResource(KEY);
-                    if (txConnections != null && txConnections.size() > 0) {
+                connectionObjects.put(connectionInfo, connectionInfo.getConnectionProxy());
 
-                        for (final ManagedConnectionInfo managedConnectionInfo : txConnections.keySet())
{
-                            final StringBuilder sb = new StringBuilder();
-                            final Collection<ConnectionInfo> connectionInfos = txConnections.get(managedConnectionInfo).keySet();
-                            for (final ConnectionInfo connectionInfo : connectionInfos) {
-                                sb.append("\n  ").append("Connection handle opened at ").append(stackTraceToString(connectionInfo.getTrace().getStackTrace()));
-                            }
+                registry.registerInterposedSynchronization(new Synchronization() {
+                    @Override
+                    public void beforeCompletion() {
+                        final Map<ManagedConnectionInfo, Map<ConnectionInfo, Object>>
txConnections = (Map<ManagedConnectionInfo, Map<ConnectionInfo, Object>>) registry.getResource(KEY);
+                        if (txConnections != null && txConnections.size() > 0)
{
 
-                            logger.warning("Transaction complete, but connection still has
handles associated: " + managedConnectionInfo + "\nAbandoned connection information: " + sb.toString());
+                            for (final ManagedConnectionInfo managedConnectionInfo : txConnections.keySet())
{
+                                final StringBuilder sb = new StringBuilder();
+                                final Collection<ConnectionInfo> connectionInfos =
txConnections.get(managedConnectionInfo).keySet();
+                                for (final ConnectionInfo connectionInfo : connectionInfos)
{
+                                    sb.append("\n  ").append("Connection handle opened at
").append(stackTraceToString(connectionInfo.getTrace().getStackTrace()));
+                                }
+
+                                logger.warning("Transaction complete, but connection still
has handles associated: " + managedConnectionInfo + "\nAbandoned connection information: "
+ sb.toString());
+                            }
                         }
                     }
-                }
 
-                @Override
-                public void afterCompletion(final int status) {
+                    @Override
+                    public void afterCompletion(final int status) {
 
-                }
-            });
+                    }
+                });
+            }
         }
 
         if (! reassociate) {


Mime
View raw message