You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2018/10/10 16:23:27 UTC
tomee git commit: TOMEE-2257 fix test
Repository: tomee
Updated Branches:
refs/heads/tomee-1.7.x 9e3f59d39 -> e29e75d99
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/e29e75d9
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/e29e75d9
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/e29e75d9
Branch: refs/heads/tomee-1.7.x
Commit: e29e75d99b734882110ac48ae9f8ecec34887edc
Parents: 9e3f59d
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Oct 10 17:22:52 2018 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Oct 10 17:22:52 2018 +0100
----------------------------------------------------------------------
.../openejb/resource/AutoConnectionTracker.java | 72 ++++++++++----------
1 file changed, 37 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/e29e75d9/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 d47a795..2da5ffb 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
@@ -100,51 +100,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) {