You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by da...@apache.org on 2006/08/06 05:26:45 UTC

svn commit: r429099 - /geronimo/branches/dain/notcm/modules/connector/src/java/org/apache/geronimo/connector/ConnectorTransactionContext.java

Author: dain
Date: Sat Aug  5 20:26:45 2006
New Revision: 429099

URL: http://svn.apache.org/viewvc?rev=429099&view=rev
Log:
Synchronize ConnectorTransactionContext.managedConnections - This is not necessary since this method is only called by the thread associated with the transaction and only on thread can be associated with the transaction at a time.  But, it is just safe and since there will be no contention, this won't hurt performance.

Modified:
    geronimo/branches/dain/notcm/modules/connector/src/java/org/apache/geronimo/connector/ConnectorTransactionContext.java

Modified: geronimo/branches/dain/notcm/modules/connector/src/java/org/apache/geronimo/connector/ConnectorTransactionContext.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/connector/src/java/org/apache/geronimo/connector/ConnectorTransactionContext.java?rev=429099&r1=429098&r2=429099&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/connector/src/java/org/apache/geronimo/connector/ConnectorTransactionContext.java (original)
+++ geronimo/branches/dain/notcm/modules/connector/src/java/org/apache/geronimo/connector/ConnectorTransactionContext.java Sat Aug  5 20:26:45 2006
@@ -65,14 +65,14 @@
 
     private Map managedConnections;
 
-    public Object getManagedConnectionInfo(ConnectionReleaser key) {
+    public synchronized Object getManagedConnectionInfo(ConnectionReleaser key) {
         if (managedConnections == null) {
             return null;
         }
         return managedConnections.get(key);
     }
 
-    public void setManagedConnectionInfo(ConnectionReleaser key, Object info) {
+    public synchronized void setManagedConnectionInfo(ConnectionReleaser key, Object info) {
         if (managedConnections == null) {
             managedConnections = new HashMap();
         }
@@ -93,15 +93,17 @@
 
         public void afterCompletion(int status) {
             try {
-                if (ctx.managedConnections != null) {
-                    for (Iterator entries = ctx.managedConnections.entrySet().iterator(); entries.hasNext();) {
-                        Map.Entry entry = (Map.Entry) entries.next();
-                        ConnectionReleaser key = (ConnectionReleaser) entry.getKey();
-                        key.afterCompletion(entry.getValue());
+                synchronized (ctx) {
+                    if (ctx.managedConnections != null) {
+                        for (Iterator entries = ctx.managedConnections.entrySet().iterator(); entries.hasNext();) {
+                            Map.Entry entry = (Map.Entry) entries.next();
+                            ConnectionReleaser key = (ConnectionReleaser) entry.getKey();
+                            key.afterCompletion(entry.getValue());
+                        }
+                        //If BeanTransactionContext never reuses the same instance for sequential BMT, this
+                        //clearing is unnecessary.
+                        ctx.managedConnections.clear();
                     }
-                    //If BeanTransactionContext never reuses the same instance for sequential BMT, this
-                    //clearing is unnecessary.
-                    ctx.managedConnections.clear();
                 }
             } finally {
                 remove(transaction);