Author: peter_firmstone
Date: Mon Nov 18 21:54:21 2013
New Revision: 1543183

URL: http://svn.apache.org/r1543183
Log:
Fix Mahalo's use of ConcurrentMap to utilise concurrent methods, originally 
Mahalo used HashMap, this was refactored to ConcurrentMap to ensure visibility 
between threads.

Modified:
    
river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/TxnManagerImpl.java

Modified: 
river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/TxnManagerImpl.java
URL: 
http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/TxnManagerImpl.java?rev=1543183&r1=1543182&r2=1543183&view=diff
==============================================================================
--- 
river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/TxnManagerImpl.java 
(original)
+++ 
river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/TxnManagerImpl.java 
Mon Nov 18 21:54:21 2013
@@ -558,7 +558,7 @@ class TxnManagerImpl /*extends RemoteSer
             try {
                 str = serverTransaction(tr);
                 TxnManagerTransaction existed = 
txns.putIfAbsent(Long.valueOf(str.id), txntr);
-                /* This should never happen, but in the unprobable event we 
get a collision */
+                /* This should never happen, but in the improbable event we 
get a collision */
                 if (existed == null){ 
                     todoPut = false;
                     expMgr.register(txntr);
@@ -721,7 +721,7 @@ class TxnManagerImpl /*extends RemoteSer
 
        // txntr.commit does expiration check
        txntr.commit(waitFor);
-        txns.remove(Long.valueOf(id));
+        txns.remove(Long.valueOf(id), txntr); // Only removed if commit 
doesn't throw exception.
 
        if (transactionsLogger.isLoggable(Level.FINEST)) {
             transactionsLogger.log(Level.FINEST,
@@ -809,7 +809,7 @@ class TxnManagerImpl /*extends RemoteSer
             if (t instanceof Error) throw (Error) t;
             if (t instanceof RuntimeException) throw (RuntimeException) t;
         }
-       txns.remove(Long.valueOf(id));
+       txns.remove(Long.valueOf(id), txntr);
 
        if (transactionsLogger.isLoggable(Level.FINEST)) {
             transactionsLogger.log(Level.FINEST,
@@ -1202,10 +1202,11 @@ class TxnManagerImpl /*extends RemoteSer
             * their expirations are irrelevant. Therefore, any recovered
             * transactions are effectively lease.FOREVER. 
             */
+            
+            TxnManagerTransaction existed = txns.putIfAbsent(key, tmt);
+            if (existed != null) tmt = existed;
        }
 
-       txns.put(key, tmt);
-
         if (operationsLogger.isLoggable(Level.FINER)) {
             operationsLogger.exiting(TxnManagerImpl.class.getName(), 
                "enterTMT", tmt);


Reply via email to