river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter_firmst...@apache.org
Subject svn commit: r1470272 [1/2] - in /river/jtsk/skunk/qa_refactor/trunk: qa/ qa/src/com/sun/jini/test/impl/outrigger/leasing/ qa/src/com/sun/jini/test/share/ src/com/sun/jini/mahalo/ src/com/sun/jini/outrigger/ src/com/sun/jini/outrigger/snaplogstore/ src/...
Date Sun, 21 Apr 2013 07:53:25 GMT
Author: peter_firmstone
Date: Sun Apr 21 07:53:23 2013
New Revision: 1470272

URL: http://svn.apache.org/r1470272
Log:
Removed remote export from Outrigger constructor that allows "this" reference to escape.

Spent time ensuring fields are visible to other threads, including some test fields.

More time needs to be spend checking synchronization of OutriggerServerImpl components, to audit synchronization and locking performed on objects / fields.


Modified:
    river/jtsk/skunk/qa_refactor/trunk/qa/build.xml
    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/leasing/LeaseUsesTestBase.java
    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LeaseGrantTestBase.java
    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LeaseUsesTestBase.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/SettlerTask.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/TxnManagerImpl.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/TxnManagerTransaction.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/AvailabilityRegistrationWatcher.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/BaseHandle.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/ConsumingWatcher.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHandle.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHandleHashDesc.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHandleTmplDesc.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHolder.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryRep.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EventRegistrationWatcher.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/FastList.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/IteratorProxy.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/JavaSpaceAdmin.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/JoinStateManager.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/MatchSetProxy.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OperationJournal.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OutriggerServerImpl.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/SingletonQueryWatcher.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/SnapshotRep.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/StorableReference.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TakeIfExistsWatcher.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/ThrowThis.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TransactableReadIfExistsWatcher.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/Txn.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnMonitorTask.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnState.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TypeTree.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/WrittenEntry.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/snaplogstore/BackEnd.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/snaplogstore/BaseObject.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/snaplogstore/ByteArrayWrapper.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/snaplogstore/LogFile.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/snaplogstore/LogInputFile.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/snaplogstore/LogOutputFile.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/snaplogstore/LogOutputStream.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/snaplogstore/LogStore.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/snaplogstore/PendingTxn.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/snaplogstore/Registration.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/snaplogstore/Resource.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/snaplogstore/SnapshotFile.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/RetryTask.java
    river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/transaction/TransactionException.java
    river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/transaction/UnknownTransactionException.java

Modified: river/jtsk/skunk/qa_refactor/trunk/qa/build.xml
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/build.xml?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/qa/build.xml (original)
+++ river/jtsk/skunk/qa_refactor/trunk/qa/build.xml Sun Apr 21 07:53:23 2013
@@ -1535,7 +1535,6 @@
     <target name="qa1-share.stubs" depends="compile">
         <rmic base="${build.classes.dir}" stubversion="1.2" classpathref="river.jars">
             <include name="com/sun/jini/test/share/KillVMUtil$$KillVMObjectImpl.class" />
-            <include name="com/sun/jini/test/share/reggie/RegistrarImpl.class" />
             <include name="com/sun/jini/test/share/TesterTransactionManager.class" />
             <include name="com/sun/jini/test/share/LeaseBackEndImpl.class" />
             <include name="com/sun/jini/test/share/TestParticipantImpl.class" />
@@ -1552,11 +1551,6 @@
             <arg pathref="classdep.cp"/>
             <arg value="-files"/>
             <arg line="-in com.sun.jini.test"/>
-            <arg line="com.sun.jini.test.share.reggie.RegistrarProxy"/>
-            <arg line="com.sun.jini.test.share.reggie.RegistrarAdminProxy"/>
-            <arg line="com.sun.jini.test.share.reggie.EventLease"/>
-            <arg line="com.sun.jini.test.share.reggie.Registration"/>
-            <arg line="com.sun.jini.test.share.reggie.RegistrarEvent"/>
             <arg line="com.sun.jini.test.share.AttrOne"/>
             <arg line="com.sun.jini.test.share.AttrTwo"/>
             <arg line="com.sun.jini.test.share.SunOfAttrOne"/>
@@ -1568,7 +1562,6 @@
             <arg line="com.sun.jini.test.share.TesterTransactionManagerProxyVerifier"/>
             <arg line="com.sun.jini.test.share.LeaseBackEndImpl$$VerifierImpl"/>
             <arg line="com.sun.jini.test.share.KillVMUtil$$KillVMObjectImpl_Stub"/>
-            <arg line="com.sun.jini.test.share.reggie.RegistrarImpl_Stub"/>
             <arg line="com.sun.jini.test.share.TesterTransactionManager_Stub"/>
             <arg line="com.sun.jini.test.share.LeaseBackEndImpl_Stub"/>
             <arg line="com.sun.jini.test.share.TestParticipantImpl_Stub"/>
@@ -1586,17 +1579,11 @@
             <arg line="-in net.jini"/>
             <arg line="${jskplatform.exclude}"/>
             <arg line="-hide com.sun.jini.test"/>
-            <arg line="com.sun.jini.test.share.reggie.RegistrarProxy"/>
-            <arg line="com.sun.jini.test.share.reggie.RegistrarAdminProxy"/>
-            <arg line="com.sun.jini.test.share.reggie.EventLease"/>
-            <arg line="com.sun.jini.test.share.reggie.Registration"/>
-            <arg line="com.sun.jini.test.share.reggie.RegistrarEvent"/>
             <arg line="com.sun.jini.test.share.TesterTransactionManagerProxy"/>
             <arg line="com.sun.jini.test.share.TesterTransactionManagerConstrainableProxy"/>
             <arg line="com.sun.jini.test.share.TesterTransactionManagerProxyVerifier"/>
             <arg line="com.sun.jini.proxy.BasicProxyTrustVerifier"/>
             <arg line="com.sun.jini.test.share.KillVMUtil$$KillVMObjectImpl_Stub"/>
-            <arg line="com.sun.jini.test.share.reggie.RegistrarImpl_Stub"/>
             <arg line="com.sun.jini.test.share.TesterTransactionManager_Stub"/>
             <arg line="com.sun.jini.test.share.LeaseBackEndImpl_Stub"/>
             <arg line="com.sun.jini.test.share.TestParticipantImpl_Stub"/>
@@ -1619,10 +1606,7 @@
             <arg value="-files"/>
             <arg line="-in net.jini"/>
             <arg line="-in com.sun.jini"/>
-            <arg line="com.sun.jini.test.share.reggie.RegistrarImpl"/>
-            <arg line="com.sun.jini.test.share.reggie.CreateLookup"/>
             <arg line="com.sun.jini.test.share.KillVMUtil$$KillVMObjectImpl_Stub"/>
-            <arg line="com.sun.jini.test.share.reggie.RegistrarImpl_Stub"/>
             <arg line="com.sun.jini.test.share.TesterTransactionManager_Stub"/>
             <arg line="com.sun.jini.test.share.LeaseBackEndImpl_Stub"/>
             <arg line="com.sun.jini.test.share.TestParticipantImpl_Stub"/>
@@ -1648,17 +1632,11 @@
             <arg value="-files"/>
             <arg line="-in net.jini"/>
             <arg line="-in com.sun.jini"/>
-            <arg line="com.sun.jini.test.share.reggie.RegistrarProxy"/>
-            <arg line="com.sun.jini.test.share.reggie.RegistrarAdminProxy"/>
-            <arg line="com.sun.jini.test.share.reggie.EventLease"/>
-            <arg line="com.sun.jini.test.share.reggie.Registration"/>
-            <arg line="com.sun.jini.test.share.reggie.RegistrarEvent"/>
             <arg line="net.jini.lookup.entry.Name"/>
             <arg line="net.jini.lookup.entry.ServiceInfo"/>
             <arg line="com.sun.jini.lookup.entry.BasicServiceType"/>
             <arg line="com.sun.jini.reliableLog.LogException"/>
             <arg line="com.sun.jini.test.share.KillVMUtil$$KillVMObjectImpl_Stub"/>
-            <arg line="com.sun.jini.test.share.reggie.RegistrarImpl_Stub"/>
             <arg line="com.sun.jini.test.share.TesterTransactionManager_Stub"/>
             <arg line="com.sun.jini.test.share.LeaseBackEndImpl_Stub"/>
             <arg line="com.sun.jini.test.share.TestParticipantImpl_Stub"/>

Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/leasing/LeaseUsesTestBase.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/leasing/LeaseUsesTestBase.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/leasing/LeaseUsesTestBase.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/outrigger/leasing/LeaseUsesTestBase.java Sun Apr 21 07:53:23 2013
@@ -278,9 +278,9 @@ public abstract class LeaseUsesTestBase 
         if (cancelSlop > 0) {
 	    logger.log(Level.INFO, 
 		       "Sleeping for {0}" + " milliseconds to "
-		       + "allow cancel to propagate...", cancelSlop);
+		       + "allow cancel to propagate... time: {1}", new Object[] {cancelSlop, System.currentTimeMillis()});
 	    Thread.sleep(cancelSlop);
-	    logger.log(Level.INFO, "awake");
+	    logger.log(Level.INFO, "awake: {0}", System.currentTimeMillis());
         }
         logger.log(Level.INFO, 
 		   "Cancel Test: checking to make sure resource " + "is gone");

Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LeaseGrantTestBase.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LeaseGrantTestBase.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LeaseGrantTestBase.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LeaseGrantTestBase.java Sun Apr 21 07:53:23 2013
@@ -34,12 +34,12 @@ import net.jini.admin.Administrable;
 public abstract class LeaseGrantTestBase extends TestBase implements Test {
     // If true then the tests expects leases to granted
     // exactly.  If false the grant can be for less than the request
-    private boolean exact = false; 
+    private volatile boolean exact = false; 
 
     /**
      * The length of time the lease should be asked for.
      */
-    protected long durationRequest;
+    protected volatile long durationRequest;
 
     /**
      * The expiration time that would be given for the duration request
@@ -47,26 +47,26 @@ public abstract class LeaseGrantTestBase
      * <code>Lease.ANY</code>.
      * @see #resourceRequested
      */
-    protected long expirationRequest;
+    protected volatile long expirationRequest;
 
     /**
      * The local time just after the request.  <code>expirationRequest</code>
      * is <code>requestStart + durationRequest</code>.
      * @see #resourceRequested
      */
-    protected long requestStart;
+    protected volatile long requestStart;
 
     /**
      * The length of time that leases get cliped to if they are too
      * long. A negative value indicates no cliping is expected
      */
-    protected long clip = -1;
+    protected volatile long clip = -1;
 
     /*
      * Acceptable slop interval between when we think lease will
      * expire and when it acctually does.
      */
-    protected long slop = 2000;
+    protected volatile long slop = 2000;
     
     /**
      * Test the passed lease to see if it has been granted for an

Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LeaseUsesTestBase.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LeaseUsesTestBase.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LeaseUsesTestBase.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LeaseUsesTestBase.java Sun Apr 21 07:53:23 2013
@@ -38,22 +38,22 @@ public abstract class LeaseUsesTestBase 
     /**
      * Lease being used
      */
-    protected Lease lease = null;
+    protected volatile Lease lease = null;
 
     // Time lease will expire
-    private long expTime;
+    private volatile long expTime;
 
     // Time lease of lease duration
-    private long durTime;
+    private volatile long durTime;
 
     // How long until the lease should be renewed
-    private long renewTime;
+    private volatile long renewTime;
 
     // What to set renewTime to, if < 0 the half of duration
-    private long renewWait;
+    private volatile long renewWait;
 
     // Time to let cancel to propgate
-    private long cancelSlop;
+    private volatile long cancelSlop;
 
     // Set renew and exp times
     private void setTimes() {
@@ -68,10 +68,10 @@ public abstract class LeaseUsesTestBase 
 	    renewTime = renewWait + curTime;
     }
 
-    protected long renewals = 0;
-    protected boolean cancel;
-    protected long shutdownTime = -1;
-    protected long restartSleep = 10000;
+    protected volatile long renewals = 0;
+    protected volatile boolean cancel;
+    protected volatile long shutdownTime = -1;
+    protected volatile long restartSleep = 10000;
 
     /** 
      * Method should acquire some resource under a lease and return
@@ -142,7 +142,7 @@ public abstract class LeaseUsesTestBase 
 	if (cancel && renewals <= 0) {
 	    cancel();
 	} else {
-	    logger.log(Level.INFO, "Expire Test: Slop = " + slop);
+	    logger.log(Level.INFO, "Expire Test: Slop = {0}", slop);
 	    while (true) {
 		// We measure the time twice so propagation delays do
 		// not cause the test to fail.  The test only fails on
@@ -235,10 +235,11 @@ public abstract class LeaseUsesTestBase 
 	// easer to code
 	if (cancelSlop > 0) {
 	    try {
-		logger.log(Level.INFO, "Sleeping for " + cancelSlop + " milliseconds to " +
-			  "allow cancel to propagate...");
+		logger.log(Level.INFO, "Sleeping for {0}" +
+			  " milliseconds to " + "allow cancel to propagate... time:{1}", new Object[]{cancelSlop, System.currentTimeMillis()});
 		Thread.sleep(cancelSlop);
-		logger.log(Level.INFO, "awake");
+		logger.log(Level.INFO, "awake ... time:{0}", System.currentTimeMillis());
+                
 	    } catch (InterruptedException e) {
 		// Should not happen
 		throw new TestException("Cancel slop sleep interupted!");

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/SettlerTask.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/SettlerTask.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/SettlerTask.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/SettlerTask.java Sun Apr 21 07:53:23 2013
@@ -21,8 +21,8 @@ import com.sun.jini.logging.Levels;
 import com.sun.jini.thread.RetryTask;
 import com.sun.jini.thread.TaskManager;
 import com.sun.jini.thread.WakeupManager;
-import java.rmi.RemoteException;
 import java.rmi.NoSuchObjectException;
+import java.rmi.RemoteException;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -40,8 +40,6 @@ import net.jini.core.transaction.server.
 
 public class SettlerTask extends RetryTask implements TransactionConstants {
     private final long tid;
-    private int attempt; // sync on this.
-    private final int maxtries = Integer.MAX_VALUE;
     private final TransactionManager txnmgr;
 
     /** Logger for operations related messages */
@@ -89,12 +87,8 @@ public class SettlerTask extends RetryTa
 	        "tryOnce");
 	}
         try {
-            synchronized (this){
-	    if (attempt >= maxtries)
-		return true;
-
-	    attempt++;
-            }
+            // There was previously a check to see if max tries (an int) was
+            // greater than Integer.MAX_VALUE that returned true, the condition was never true.
 
 	    if (transactionsLogger.isLoggable(Level.FINEST)) {
                 transactionsLogger.log(Level.FINEST,
@@ -119,6 +113,8 @@ public class SettlerTask extends RetryTa
 		    "Attempting to settle transaction in an invalid state: {0}", 
 		    Integer.valueOf(state));
 	        }
+                System.err.println("Attempting to settle transaction in an invalid state:" + 
+		    Integer.valueOf(state));
 	    }
 
 	} catch (NoSuchObjectException nsoe) {
@@ -126,12 +122,14 @@ public class SettlerTask extends RetryTa
 		transactionsLogger.log(Level.WARNING,
 		"Unable to settle recovered transaction", nsoe);
 	    }
+            nsoe.printStackTrace(System.err);
 //TODO -ignore?	    
         } catch (TransactionException te) {
 	    if(transactionsLogger.isLoggable(Levels.HANDLED)) {
 		transactionsLogger.log(Levels.HANDLED,
 		"Unable to settle recovered transaction", te);
 	    }
+            te.printStackTrace(System.err);
 //TODO -ignore?	    
         } catch (RemoteException re) {
 	    //try again
@@ -139,6 +137,7 @@ public class SettlerTask extends RetryTa
                 operationsLogger.exiting(SettlerTask.class.getName(), 
 	            "tryOnce", Boolean.valueOf(false));
 	    }
+            re.printStackTrace(System.err);
 	    return false;
 	}
 

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=1470272&r1=1470271&r2=1470272&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 Sun Apr 21 07:53:23 2013
@@ -61,7 +61,9 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Queue;
 import java.util.Vector;
+import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.ConcurrentMap;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -166,7 +168,7 @@ class TxnManagerImpl /*extends RemoteSer
     /* Map of transaction ids are their associated, internal 
      * transaction representations */
     private final ConcurrentMap<Long,TxnManagerTransaction> txns;
-    private final Vector<Long> unsettledtxns = new Vector<Long>();
+    private final Queue<Long> unsettledtxns = new ConcurrentLinkedQueue<Long>();
     private final InterruptedStatusThread settleThread;
     private final String persistenceDirectory;
     private final ActivationID activationID;
@@ -216,7 +218,7 @@ class TxnManagerImpl /*extends RemoteSer
     private AccessControlContext context;
     private Throwable thrown;
     // sync on this.
-    private boolean startOnce = false;
+    private boolean started = false;
 
     /**
      * Constructs a non-activatable transaction manager.
@@ -396,8 +398,8 @@ class TxnManagerImpl /*extends RemoteSer
 
     public void start() throws Exception {
         synchronized (this){
-            if (startOnce) return;
-            startOnce = true;
+            if (started) return;
+            started = true;
         }
         try {
             if (thrown != null) throw thrown;
@@ -516,62 +518,72 @@ class TxnManagerImpl /*extends RemoteSer
 	}
         readyState.check();
     
-	TxnManagerTransaction txntr = null;
+	TxnManagerTransaction txntr;
+        Lease txnmgrlease = null;
+        ServerTransaction str = null;
+        // following section must be performed atomically, or duplicate ID might be assigned.
+        boolean todoPut = true;
+        while (todoPut){
+            long tid = nextID();
+            Uuid uuid = createLeaseUuid(tid);
 
-	long tid = nextID();
-        Uuid uuid = createLeaseUuid(tid);
-
-        if (transactionsLogger.isLoggable(Level.FINEST)) {
-            transactionsLogger.log(Level.FINEST, 
-	        "Transaction ID is: {0}", Long.valueOf(tid));
-	}
-
-        txntr = new TxnManagerTransaction(
-	    txnMgrProxy, logmgr, tid, taskpool, 
-	    taskWakeupMgr, this, uuid);
-	Lease txnmgrlease = null;
-	try {
-            Result r = txnLeasePeriodPolicy.grant(txntr, lease);
-            txntr.setExpiration(r.expiration);
-            txnmgrlease = 
-	        leaseFactory.newLease(
-		    uuid,
-	            r.expiration);
-            expMgr.register(txntr);		
-	} catch (LeaseDeniedException lde) {
-            // Should never happen in our implementation.
-            throw new AssertionError("Transaction lease was denied" + lde);
-        }
+            if (transactionsLogger.isLoggable(Level.FINEST)) {
+                transactionsLogger.log(Level.FINEST, 
+                    "Transaction ID is: {0}", Long.valueOf(tid));
+            }
 
-        if (transactionsLogger.isLoggable(Level.FINEST)) {
-            transactionsLogger.log(Level.FINEST, 
-	        "Created new TxnManagerTransaction ID is: {0}", Long.valueOf(tid));
-	}
+            txntr = new TxnManagerTransaction(
+                txnMgrProxy, logmgr, tid, taskpool, 
+                taskWakeupMgr, this, uuid);
+            try {
+                Result r = txnLeasePeriodPolicy.grant(txntr, lease);
+                txntr.setExpiration(r.expiration);
+                txnmgrlease = 
+                    leaseFactory.newLease(
+                        uuid,
+                        r.expiration);
+                		
+            } catch (LeaseDeniedException lde) {
+                // Should never happen in our implementation.
+                throw new AssertionError("Transaction lease was denied" + lde);
+            }
 
-	Transaction tr = txntr.getTransaction();
-	ServerTransaction str = null;
+            if (transactionsLogger.isLoggable(Level.FINEST)) {
+                transactionsLogger.log(Level.FINEST, 
+                    "Created new TxnManagerTransaction ID is: {0}", Long.valueOf(tid));
+            }
 
-        try {
-	    str = serverTransaction(tr);
-	    txns.put(Long.valueOf(str.id), txntr);
+            Transaction tr = txntr.getTransaction();
 
-            if (transactionsLogger.isLoggable(Level.FINEST)) {
-                transactionsLogger.log(Level.FINEST,
-		    "recorded new TxnManagerTransaction", txntr);
-	    }
+            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 */
+                if (existed == null){ 
+                    todoPut = false;
+                    expMgr.register(txntr);
+                } else {
+                    
+                }
+                if (transactionsLogger.isLoggable(Level.FINEST)) {
+                    transactionsLogger.log(Level.FINEST,
+                        "recorded new TxnManagerTransaction", txntr);
+                }
 
 
-        } catch(Exception e) {
-	    if (transactionsLogger.isLoggable(Level.FINEST)) {
-                transactionsLogger.log(Level.FINEST,
-		"Problem creating transaction", e);
-	    }
-	    RuntimeException wrap =
-	        new RuntimeException("Unable to create transaction", e);
-	    transactionsLogger.throwing(
-	        TxnManagerImpl.class.getName(), "create", wrap);
-	    throw wrap;
-	}
+            } catch(Exception e) {
+                if (transactionsLogger.isLoggable(Level.FINEST)) {
+                    transactionsLogger.log(Level.FINEST,
+                    "Problem creating transaction", e);
+                }
+                todoPut = false;
+                RuntimeException wrap =
+                    new RuntimeException("Unable to create transaction", e);
+                transactionsLogger.throwing(
+                    TxnManagerImpl.class.getName(), "create", wrap);
+                throw wrap;
+            }
+        }
 
         TransactionManager.Created tmp = 	
 	    new TransactionManager.Created(str.id, txnmgrlease);		       
@@ -654,10 +666,10 @@ class TxnManagerImpl /*extends RemoteSer
 		TxnManagerImpl.class.getName(), "getState", 
 	        Integer.valueOf(state));
 	}
-	return state;
+            return state;
         } catch (TransactionException ex) {
-            throw new UnknownTransactionException("unknown transaction");
-    }
+            throw new UnknownTransactionException("Transaction expired", ex);
+        }
     }
 
 
@@ -697,8 +709,7 @@ class TxnManagerImpl /*extends RemoteSer
 	}
         readyState.check();
 
-	TxnManagerTransaction txntr =
-		(TxnManagerTransaction) txns.get(Long.valueOf(id));
+	TxnManagerTransaction txntr = txns.get(Long.valueOf(id));
 
 	if (transactionsLogger.isLoggable(Level.FINEST)) {
             transactionsLogger.log(Level.FINEST,
@@ -845,24 +856,23 @@ class TxnManagerImpl /*extends RemoteSer
      *
      * @param tid the transaction's ID
      */
-    public synchronized void noteUnsettledTxn(long tid) {
+    public void noteUnsettledTxn(long tid) {
         if (operationsLogger.isLoggable(Level.FINER)) {
             operationsLogger.entering(TxnManagerImpl.class.getName(), 
 	        "noteUnsettledTxn", new Object[] {Long.valueOf(tid)});
 	}
 	unsettledtxns.add(Long.valueOf(tid));
-
-	notifyAll();
-
+        synchronized (this){
+            notifyAll();
+        }
+        
         if (operationsLogger.isLoggable(Level.FINER)) {
             operationsLogger.exiting(TxnManagerImpl.class.getName(), 
 	        "noteUnsettledTxn");
 	}
     }
 
-    private synchronized void settleTxns() throws InterruptedException {
-	ClientLog log = null;
-
+    private void settleTxns() throws InterruptedException {
         if (operationsLogger.isLoggable(Level.FINER)) {
             operationsLogger.entering(TxnManagerImpl.class.getName(), 
 	        "settleTxns");
@@ -870,24 +880,25 @@ class TxnManagerImpl /*extends RemoteSer
 	if (transactionsLogger.isLoggable(Level.FINEST)) {
             transactionsLogger.log(Level.FINEST,
                 "Settling {0} transactions.", 
-		Integer.valueOf(unsettledtxns.size()));
+		Integer.valueOf(unsettledtxns.size())); //O(n)
 	}
 
-	int numtxns = 0;
 	Long first = null;
 	long tid = 0;
 
 	while (true) {
-		numtxns = unsettledtxns.size();
+            first = unsettledtxns.poll();
 
-	    if (numtxns == 0) {
+	    if (first == null) {
 	        if (transactionsLogger.isLoggable(Level.FINEST)) {
                     transactionsLogger.log(Level.FINEST,
                         "Settler waiting");
 	        }
                 // Don't wait forever, in case we're not notified, break out
                 // early and check condition.
-		wait(10000L); 
+                synchronized (this){
+                    wait(10000L); 
+                }
                 // Due to spurious wakeup and break out after ten seconds, the following log message is inaccurate.
 //	        if (transactionsLogger.isLoggable(Level.FINEST)) {
 //                    transactionsLogger.log(Level.FINEST,
@@ -896,16 +907,11 @@ class TxnManagerImpl /*extends RemoteSer
 		continue;
 	    }
 
-	    first = null;
-
-	    first = (Long) unsettledtxns.firstElement();
 	    tid = first.longValue();
 
 	    SettlerTask task = 
-	        new SettlerTask(
-		    settlerpool, settlerWakeupMgr, this, tid);
+	        new SettlerTask(settlerpool, settlerWakeupMgr, this, tid);
 	    settlerpool.add(task);
-	    unsettledtxns.remove(first);
 
             if (settleThread.hasBeenInterrupted()) 
 	        throw new InterruptedException("settleTxns interrupted");
@@ -915,12 +921,6 @@ class TxnManagerImpl /*extends RemoteSer
                     "Added SettlerTask for tid {0}", Long.valueOf(tid));
 	    }
 	}
-	// Not reachable
-        /*
-	 * if (operationsLogger.isLoggable(Level.FINER)) {
-            operationsLogger.exiting(TxnManagerImpl.class.getName(), 
-	 *   "settleTxns");
-	 */
     }
 
 

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/TxnManagerTransaction.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/TxnManagerTransaction.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/TxnManagerTransaction.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/TxnManagerTransaction.java Sun Apr 21 07:53:23 2013
@@ -445,14 +445,14 @@ class TxnManagerTransaction
 	}
 	//if the lease has expired, or the state is not
 	//amenable there is no need to continue
-
-	if (getState() != ACTIVE)
-	    throw new CannotJoinException("not active");
-
-	if ((getState() == ACTIVE) && (ensureCurrent() == false)) {
-	    doAbort(0);
-	    throw new CannotJoinException("Lease expired");
-	}
+        synchronized (jobLock){ // Following checked atomically.
+            if (getState() != ACTIVE)
+                throw new CannotJoinException("not active");
+            if ((getState() == ACTIVE) && (ensureCurrent() == false)) {
+                doAbort(0);
+                throw new CannotJoinException("Lease expired");
+            }
+        }
 
 	//Create a ParticipantHandle for the new participant
 	//and mark the transactional state as ACTIVE
@@ -581,16 +581,20 @@ class TxnManagerTransaction
 
 	//If the transaction has already expired or the state
 	//is not amenable, don't even try to continue
-
-	if ((getState() == ACTIVE) && (ensureCurrent() == false)) {
-	    doAbort(0);
-	    throw new CannotCommitException("Lease expired");
-	}
-
-	if (getState() == ABORTED)
-	    throw new CannotCommitException("attempt to commit " +
-					    "ABORTED transaction");
-
+        boolean abort = false;
+        try {
+            synchronized (jobLock){
+                if ((getState() == ACTIVE) && (ensureCurrent() == false)) {
+                    abort = true;
+                    throw new CannotCommitException("Lease expired");
+                }
+                if (getState() == ABORTED)
+                    throw new CannotCommitException("attempt to commit " +
+                                                    "ABORTED transaction");
+            }
+        } finally {
+            if (abort) doAbort(0);
+        }
 
 	//Check to see if anyone joined the transaction.  Even
 	//if no one has joined, at this point, attempt to
@@ -1184,7 +1188,7 @@ class TxnManagerTransaction
     }
 
 
-    private Vector parthandles() {
+private Vector parthandles() {
         if (operationsLogger.isLoggable(Level.FINER)) {
             operationsLogger.entering(TxnManagerTransaction.class.getName(), 
 	        "parthandles");

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/AvailabilityRegistrationWatcher.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/AvailabilityRegistrationWatcher.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/AvailabilityRegistrationWatcher.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/AvailabilityRegistrationWatcher.java Sun Apr 21 07:53:23 2013
@@ -82,7 +82,8 @@ abstract class AvailabilityRegistrationW
      * The <code>TemplateHandle</code>s associated with this
      * watcher.
      */
-    private Set<TemplateHandle> owners = new java.util.HashSet<TemplateHandle>();
+    private final Set<TemplateHandle> owners = new java.util.HashSet<TemplateHandle>();
+    private volatile boolean removed = false;
 
     /**
      * The OutriggerServerImpl we are part of.
@@ -172,7 +173,7 @@ abstract class AvailabilityRegistrationW
 
 	// lock before checking the time and so we can update currentSeqNum
 	synchronized (this) {
-	    if (owners == null) 
+	    if (removed) 
 		return; // Must have been removed
 
 	    if (now > expiration) {
@@ -222,7 +223,7 @@ abstract class AvailabilityRegistrationW
      *        <code>null</code> 
      */
     synchronized boolean addTemplateHandle(TemplateHandle h) {
-	if (owners == null)
+	if (removed)
 	    return false; // Already removed!
 
 	owners.add(h);
@@ -285,15 +286,16 @@ abstract class AvailabilityRegistrationW
 	final Set<TemplateHandle> owners;
         OutriggerServerImpl serv;
 	synchronized (this) {
-	    if (this.owners == null)
+	    if (removed)
 		return false; // already removed
 
 	    // Is this a force, or past our expiration?
 	    if (!doIt && (now < expiration))
 		return false; // don't remove, not our time
 
-	    owners = this.owners; // Don't need to clone
-            this.owners = null; // now it's null, it doesn't need sync anymore.
+	    owners = new java.util.HashSet<TemplateHandle>(this.owners); // Don't need to clone
+            this.owners.clear(); // now it's null, it doesn't need sync anymore.
+            removed = true;
 	    expiration = Long.MIN_VALUE; //Make sure no one tries to renew us
             serv = server;
 	}
@@ -349,7 +351,7 @@ abstract class AvailabilityRegistrationW
 	    boolean doneFor = false;
 
 	    synchronized (AvailabilityRegistrationWatcher.this) {
-		if (owners == null)
+		if (removed)
 		    return; // Our registration must been 
 		            // canceled/expired, don't send event
 

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/BaseHandle.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/BaseHandle.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/BaseHandle.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/BaseHandle.java Sun Apr 21 07:53:23 2013
@@ -24,7 +24,7 @@ package com.sun.jini.outrigger;
  *
  */
 class BaseHandle extends FastList.Node {
-    private EntryRep	rep;		// the rep this handle manages
+    private final EntryRep	rep;		// the rep this handle manages
 
     /**
      * Create a new handle

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/ConsumingWatcher.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/ConsumingWatcher.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/ConsumingWatcher.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/ConsumingWatcher.java Sun Apr 21 07:53:23 2013
@@ -17,6 +17,7 @@
  */
 package com.sun.jini.outrigger;
 
+import java.util.Map;
 import java.util.WeakHashMap;
 import net.jini.core.transaction.TransactionException;
 import net.jini.space.InternalSpaceException;
@@ -46,7 +47,7 @@ class ConsumingWatcher extends Singleton
      * we would have liked to return, but have been provisionally
      * removed.
      */
-    private final WeakHashMap provisionallyRemovedEntrySet;
+    private final Map provisionallyRemovedEntrySet;
 
     /**
      * Create a new <code>ConsumingWatcher</code>.
@@ -73,7 +74,7 @@ class ConsumingWatcher extends Singleton
      *        <code>false</code> otherwise.  
      */
     ConsumingWatcher(long expiration, long timestamp, long startOrdinal, 
-		     WeakHashMap provisionallyRemovedEntrySet, Txn txn,
+		     Map provisionallyRemovedEntrySet, Txn txn,
 		     boolean takeIt)
     {
 	super(expiration, timestamp, startOrdinal);

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHandle.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHandle.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHandle.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHandle.java Sun Apr 21 07:53:23 2013
@@ -219,7 +219,7 @@ class EntryHandle extends BaseHandle imp
     static EntryHandleTmplDesc descFor(EntryRep tmpl, int numFields) {
 	EntryHandleHashDesc hashDesc = new EntryHandleHashDesc();
 	EntryHandleTmplDesc tmplDesc = new EntryHandleTmplDesc();
-
+        
 	// Get the hash and the related useful information
 	tmplDesc.hash = hashFor(tmpl, numFields, hashDesc);
 
@@ -229,7 +229,7 @@ class EntryHandle extends BaseHandle imp
 	    if (i < tmpl.numFields() && tmpl.value(i) != null)
 		tmplDesc.mask |= (hashDesc.mask << (i * hashDesc.bitsPerField));
 	}
-
+        
 	// Ensure that the non-value fields are masked out
 	tmplDesc.hash &= tmplDesc.mask;
 

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHandleHashDesc.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHandleHashDesc.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHandleHashDesc.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHandleHashDesc.java Sun Apr 21 07:53:23 2013
@@ -27,13 +27,13 @@ package com.sun.jini.outrigger;
  */
 class EntryHandleHashDesc {
     /** Number of bits allocated in the hash for each field */
-    int bitsPerField;
+    volatile int bitsPerField;
 
     /** How many fields are used in the hash? */
-    int fieldsInHash;
+    volatile int fieldsInHash;
 
     /** A mask with the lower <code>bitsPerField</code> bits set */
-    long mask;
+    volatile long mask;
 
     public String toString() {
 	return bitsPerField + " bits, " + fieldsInHash + " fields, " +

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHandleTmplDesc.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHandleTmplDesc.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHandleTmplDesc.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHandleTmplDesc.java Sun Apr 21 07:53:23 2013
@@ -27,15 +27,15 @@ package com.sun.jini.outrigger;
  */
 class EntryHandleTmplDesc {
     /** The hash value for the template itself, already masked */
-    long hash;
+    volatile long hash;
 
     /**
      * The mask for EntryHandle's hash codes -- if <code>handle.hash &
      * mask != tmplDesc.hash</code>, then the template doesn't match the
      * object held by the handle.
      */
-    long mask;
-
+    volatile long mask;
+    
     public String toString() {
 	return "0x" + Long.toHexString(hash) + " & 0x" + Long.toHexString(mask);
     }

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHolder.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHolder.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHolder.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryHolder.java Sun Apr 21 07:53:23 2013
@@ -19,6 +19,7 @@ package com.sun.jini.outrigger;
 
 import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.Map;
 import java.util.Set;
 import java.util.WeakHashMap;
 import java.util.logging.Level;
@@ -116,7 +117,7 @@ class EntryHolder implements Transaction
      */
     EntryHandle hasMatch(EntryRep tmpl, TransactableMgr txn, boolean takeIt,
             Set conflictSet, Set lockedEntrySet,
-            WeakHashMap provisionallyRemovedEntrySet)
+            Map provisionallyRemovedEntrySet)
             throws CannotJoinException {
         matchingLogger.entering("EntryHolder", "hasMatch");
         EntryHandleTmplDesc desc = null;
@@ -213,7 +214,7 @@ class EntryHolder implements Transaction
      */
     boolean attemptCapture(EntryHandle handle, TransactableMgr txn,
 	boolean takeIt, Set conflictSet, Set lockedEntrySet, 
-        WeakHashMap provisionallyRemovedEntrySet, long now)
+        Map provisionallyRemovedEntrySet, long now)
     {
 	try {
 	    return confirmAvailabilityWithTxn(handle.rep(), handle,
@@ -231,7 +232,7 @@ class EntryHolder implements Transaction
     private boolean confirmAvailabilityWithTxn(EntryRep rep, 
 	      EntryHandle handle, TransactableMgr txnMgr, boolean takeIt, 
 	      long time, Set conflictSet, Set lockedEntrySet,
-	      WeakHashMap provisionallyRemovedEntrySet)
+	      Map provisionallyRemovedEntrySet)
 	throws CannotJoinException
     {
 	// Now that we know we have a match, make sure that the the
@@ -275,7 +276,7 @@ class EntryHolder implements Transaction
 	confirmAvailability(EntryRep rep, EntryHandle handle,
 	      TransactableMgr txn, boolean takeIt, long time,
 	      Set conflictSet, Set lockedEntrySet,
-	      WeakHashMap provisionallyRemovedEntrySet)
+	      Map provisionallyRemovedEntrySet)
     {
 	if (handle.removed())
 	    return false;
@@ -576,9 +577,9 @@ class EntryHolder implements Transaction
      * The class that implements <code>RepEnum</code> for this class.
      */
     private class SimpleRepEnum implements RepEnum {
-        private Iterator<EntryHandle> contentsIterator;
-	private TransactableMgr mgr;
-	private long startTime;
+        private final Iterator<EntryHandle> contentsIterator;
+	private final TransactableMgr mgr;
+	private final long startTime;
 
         SimpleRepEnum(TransactableMgr mgr) {
             this.mgr = mgr;
@@ -652,17 +653,17 @@ class EntryHolder implements Transaction
 	final private boolean takeThem;
 
 	/** <code>EntryHandleTmplDesc</code> for the templates */
-	private EntryHandleTmplDesc[] descs;
+	private volatile EntryHandleTmplDesc[] descs;
 	    
 
 	/** Time used to weed out expired entries, ok if old */
-	long now;
+	volatile long now;
 
 	/** 
 	 * Current position in parent <code>EntryHolder</code>'s
 	 * <code>contents</code> 
 	 */
-	private Iterator<EntryHandle> contentsIterator;
+	private final Iterator<EntryHandle> contentsIterator;
 
 	/**
 	 * Create a new <code>ContinuingQuery</code> object.

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryRep.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryRep.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryRep.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EntryRep.java Sun Apr 21 07:53:23 2013
@@ -68,21 +68,21 @@ class EntryRep implements StorableResour
      * The fields of the entry in marshalled form. Use <code>null</code>
      * for <code>null</code> fields.
      */
-    private MarshalledInstance[] values;
+    private volatile MarshalledInstance[] values;
 
-    private String[]	superclasses;	// class names of the superclasses
-    private long[]	hashes;		// superclass hashes
-    private long	hash;		// hash for the entry class
-    private String	className;	// the class ID of the entry
-    private String	codebase;	// the codebase for this entry class
-    private Uuid	id;		// space-relative storage id
-    private transient long	expires;// expiration time
+    private volatile String[]	superclasses;	// class names of the superclasses
+    private volatile long[]	hashes;		// superclass hashes
+    private volatile long	hash;		// hash for the entry class
+    private volatile String	className;	// the class ID of the entry
+    private volatile String	codebase;	// the codebase for this entry class
+    private volatile Uuid	id;		// space-relative storage id
+    private volatile transient long	expires;// expiration time
 
     /** 
      * <code>true</code> if the last time this object was unmarshalled 
      * integrity was being enforced, <code>false</code> otherwise.
      */
-    private transient boolean integrity;
+    private volatile transient boolean integrity;
 
     /** Comparator for sorting fields */
     private static final FieldComparator comparator = new FieldComparator();
@@ -96,6 +96,7 @@ class EntryRep implements StorableResour
     private static final EntryRep matchAnyRep;
 
     static {
+        classHashes = new WeakHashMap();
 	try {
 	    matchAnyRep = new EntryRep(new Entry() {
 		// keeps tests happy
@@ -113,7 +114,7 @@ class EntryRep implements StorableResour
      * not only would an unnecessary object creation occur, but it might
      * force the download of the actual class to the server.
      */
-    private transient Class realClass;	// real class of the contained object
+    private volatile transient Class realClass;	// real class of the contained object
 
     /** 
      * Logger for logging information about operations carried out in
@@ -157,7 +158,7 @@ class EntryRep implements StorableResour
      * Cached hash values for all classes we encounter. Weak hash used
      * in case the class is GC'ed from the client's VM.
      */
-    static private WeakHashMap	classHashes;
+    static final private WeakHashMap classHashes;
 
     /**
      * Lookup the hash value for the given class. If it is not
@@ -168,8 +169,6 @@ class EntryRep implements StorableResour
 					      boolean marshaling) 
 	throws MarshalException, UnusableEntryException
     {
-	if (classHashes == null)
-	    classHashes = new WeakHashMap();
 
 	Long hash = (Long)classHashes.get(clazz);
 
@@ -330,7 +329,7 @@ class EntryRep implements StorableResour
     EntryRep() { }
 
     /** Used to look up no-arg constructors.  */
-    private static Class[] noArg = new Class[0];
+    private final static Class[] noArg = new Class[0];
 
     /**
      * Ensure that the entry class is valid, that is, that it has appropriate

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EventRegistrationWatcher.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EventRegistrationWatcher.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EventRegistrationWatcher.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/EventRegistrationWatcher.java Sun Apr 21 07:53:23 2013
@@ -46,21 +46,21 @@ abstract class EventRegistrationWatcher 
      * Protected, but only for use by subclasses.
      * Should not be changed.
      */
-    Uuid cookie;
+    volatile Uuid cookie;
 
     /**
      * The handback associated with this registration.
      * Protected, but only for use by subclasses.
      * Should not be changed.
      */
-    MarshalledObject handback;
+    volatile MarshalledObject handback;
 
     /** 
      * The event ID associated with this registration
      * Protected, but only for use by subclasses.
      * Should not be changed.
      */
-    long eventID;
+    volatile long eventID;
 
     /** 
      * The current sequence number. 
@@ -71,7 +71,7 @@ abstract class EventRegistrationWatcher 
      * The sequence number of the last event successfully 
      * delivered.  Protected, but only for use by subclasses.
      */
-    long lastSeqNumDelivered = -1;
+    volatile long lastSeqNumDelivered = -1;
 
     /**
      * The <code>TemplateHandle</code> associated with this

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/FastList.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/FastList.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/FastList.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/FastList.java Sun Apr 21 07:53:23 2013
@@ -88,7 +88,7 @@ class FastList<T extends FastList.Node> 
          * removed from the list to which it was added. Protected by
          * synchronization on the node.
          */
-        private FastList<?> list;
+        private volatile FastList<?> list;
 
         /**
          * Remove this node from its list.

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/IteratorProxy.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/IteratorProxy.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/IteratorProxy.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/IteratorProxy.java Sun Apr 21 07:53:23 2013
@@ -46,16 +46,16 @@ class IteratorProxy implements AdminIter
      * Reference to the server.
      * Only assigned by this class.
      */
-    OutriggerAdmin server;
+    volatile OutriggerAdmin server;
 
     /** Last set of reps we got from the server */
-    private EntryRep[] reps;
+    private volatile EntryRep[] reps;
 
     /** 
      * Index of the next entry in rep to return.  If <code>delete()</code>
      * we will call <code>iter.delete()</code> next - 1
      */
-    private int next = -1;	
+    private volatile int next = -1;	
 
     /**
      * How many entries to ask for each time we go to the server
@@ -63,7 +63,7 @@ class IteratorProxy implements AdminIter
     private final int fetchSize;
 
     /** ID of last entry we got from server */
-    private Uuid lastId = null;
+    private volatile Uuid lastId = null;
     
     /**
      * Create client side iterator proxy.

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/JavaSpaceAdmin.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/JavaSpaceAdmin.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/JavaSpaceAdmin.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/JavaSpaceAdmin.java Sun Apr 21 07:53:23 2013
@@ -46,7 +46,7 @@ public interface JavaSpaceAdmin extends 
      * Can be passed to <code>contents</code> to indicate
      * no preference for the fetch size.
      */
-    int USE_DEFAULT = -1;
+    final int USE_DEFAULT = -1;
 
     /**
      * Return the space that this administrative object governs.

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/JoinStateManager.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/JoinStateManager.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/JoinStateManager.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/JoinStateManager.java Sun Apr 21 07:53:23 2013
@@ -54,24 +54,24 @@ import com.sun.jini.logging.Levels;
 // @see JoinAdminState
 class JoinStateManager implements StorableObject {
     /** <code>ProxyPreparer</code> for <code>LookupLocators</code> */
-    private ProxyPreparer lookupLocatorPreparer;
+    private volatile ProxyPreparer lookupLocatorPreparer;
 
     /**
      * Object used to find lookups. Has to implement DiscoveryManagement
      * and DiscoveryLocatorManagement as well as DiscoveryGroupManagement.
      */
-    private DiscoveryGroupManagement dgm;
+    private volatile DiscoveryGroupManagement dgm;
 
     /**
      * <code>JoinManager</code> that is handling the details of binding
      * into Jini lookup services.
      */
-    private JoinManager  mgr;
+    private volatile JoinManager  mgr;
 
     /**
      * The object that is coordinating our persistent state.
      */
-    private LogOps log;
+    private volatile LogOps log;
 
     /**
      * The list of attributes to start with. This field is only used
@@ -80,7 +80,7 @@ class JoinStateManager implements Storab
      * is kept by <code>mgr</code>. This field is nulled out by
      * <code>startManager</code>.
      */
-    private Entry[]		attributes;
+    private volatile Entry[]		attributes;
 
     /**
      * The list of <code>LookupLocator</code>s to start with. This
@@ -89,7 +89,7 @@ class JoinStateManager implements Storab
      * of attributes is kept by <code>mgr</code>. This field is nulled
      * out by <code>startManager</code>.  
      */
-    private LookupLocator	locators[];
+    private volatile LookupLocator	locators[];
 
 
     /**
@@ -99,14 +99,14 @@ class JoinStateManager implements Storab
      * is kept by <code>mgr</code>. This field is nulled out by
      * <code>startManager</code>.
      */
-    private String		groups[];
+    private volatile String		groups[];
 
     /**
      * Conceptually, true if this is the first time this
      * service has come up, implemented as if there was
      * no previous state then this is the first time.
      */
-    private boolean initial = true;
+    private volatile boolean initial = true;
 
     /** Logger for logging join related information */
     private static final Logger logger = 

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/MatchSetProxy.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/MatchSetProxy.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/MatchSetProxy.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/MatchSetProxy.java Sun Apr 21 07:53:23 2013
@@ -48,16 +48,16 @@ class MatchSetProxy implements MatchSet 
     final private Lease lease;
 
     /** Last batch fetched from server */
-    private EntryRep[] reps;
+    private volatile EntryRep[] reps;
 
     /** Last rep returned */
-    private EntryRep lastRepReturned;
+    private volatile EntryRep lastRepReturned;
 
     /** Current index into reps */
-    private int i;
+    private volatile int i;
 
     /** True if reps[i] could not be unpacked */
-    private boolean unpackFailure = true; 
+    private volatile boolean unpackFailure = true; 
 
     MatchSetProxy(MatchSetData inital, SpaceProxy2 parent, OutriggerServer space) {
 	uuid = inital.uuid;

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OperationJournal.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OperationJournal.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OperationJournal.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OperationJournal.java Sun Apr 21 07:53:23 2013
@@ -19,6 +19,7 @@ package com.sun.jini.outrigger;
 
 import java.util.SortedSet;
 import java.util.Iterator;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -52,19 +53,19 @@ class OperationJournal extends Thread {
     private final TransitionWatchers watchers;
 
     /** The current tail of the transitions list. */
-    private JournalNode tail;
+    private volatile JournalNode tail;
 
     /**
      * The <code>JournalNode</code> we are currently processing or if
      * none are in process the last one we processed.
      */
-    private JournalNode lastProcessed;
+    private volatile JournalNode lastProcessed;
 
     /** If <code>true</code> stop thread */
     private volatile boolean dead = false;
 
     /** The last ordinal value used */
-    private long lastOrdinalUsed = 1;
+    private final AtomicLong lastOrdinalUsed = new AtomicLong(1L);
 
     /** Logger for logging exceptions */
     private static final Logger logger = 
@@ -93,7 +94,7 @@ class OperationJournal extends Thread {
 	 * @param payload The value for the payload field.
 	 */
 	private JournalNode(Object payload) {
-	    ordinal = ++lastOrdinalUsed;
+	    ordinal = lastOrdinalUsed.incrementAndGet();
 	    this.payload = payload;
 	}
 
@@ -298,10 +299,8 @@ class OperationJournal extends Thread {
 	if (watchers == null)
 	    throw new NullPointerException("watchers must be non-null");
 	this.watchers = watchers;
-	synchronized (this) {
-	    tail = new JournalNode(null);
-	}
-	lastProcessed = tail;	
+        tail = new JournalNode(null);
+	lastProcessed = tail;
     }
 
     /**
@@ -340,7 +339,7 @@ class OperationJournal extends Thread {
      * @return the ordinal of the last operation posted.
      */
     synchronized long currentOrdinal() {
-	return lastOrdinalUsed;
+	return lastOrdinalUsed.get();
     }
 
     /**

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OutriggerServerImpl.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OutriggerServerImpl.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OutriggerServerImpl.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/OutriggerServerImpl.java Sun Apr 21 07:53:23 2013
@@ -99,6 +99,7 @@ import java.util.logging.Logger;
 import javax.security.auth.Subject;
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
+import net.jini.core.transaction.server.TransactionConstants;
 
 /**
  * A basic implementation of a JavaSpaces<sup><font size=-2>TM</font></sup> 
@@ -241,13 +242,13 @@ public class OutriggerServerImpl 
      * <code>EventRegistrationRecord</code> instances
      */
     final private Map<Uuid,LeasedResource> eventRegistrations =
-	Collections.synchronizedMap(new java.util.HashMap<Uuid,LeasedResource>());
+	new ConcurrentHashMap<Uuid,LeasedResource>();
 
     /**
      * A map from contents result cookies to <code>ContentsQuery</code> objects.
      */
     final private Map<Uuid,LeasedResource> contentsQueries = 
-	Collections.synchronizedMap(new java.util.HashMap<Uuid,LeasedResource>());
+	new ConcurrentHashMap<Uuid,LeasedResource>();
 
     /**
      * The transactions recovered after restart. This table
@@ -336,7 +337,7 @@ public class OutriggerServerImpl 
      * server.
      * @serial
      */
-    private final OutriggerServer ourRemoteRef;
+    private volatile OutriggerServer ourRemoteRef;
 
     /**
      * The <code>Uuid</code> for this service. Used in the 
@@ -583,7 +584,6 @@ public class OutriggerServerImpl 
             transactionManagerPreparer = h.transactionManagerPreparer;
             listenerPreparer = h.listenerPreparer;
             exporter = h.exporter;
-            ourRemoteRef = h.ourRemoteRef;
             contents = h.contents;
             templates = h.templates;
             operationJournal = h.operationJournal;
@@ -655,6 +655,7 @@ public class OutriggerServerImpl 
 
                 @Override
                 public Object run() throws Exception {
+                    ourRemoteRef = (OutriggerServer) exporter.export(serverGate);
                             // This takes a while the first time, so let's get it going
                     txnMonitor.start();
                     starter.start();
@@ -731,8 +732,10 @@ public class OutriggerServerImpl 
         } catch (Exception e) {
             // Clean up and rethrow.
             lifecycleLogger.log(Level.SEVERE, "Failed to start Outrigger server", e);
-            // If we created a JoinStateManager,
-            
+           
+            unwindExporter(ourRemoteRef, exporter);
+           
+             // If we created a JoinStateManager,
             try {
                 joinStateManager.destroy();
             } catch (Throwable t) {
@@ -796,7 +799,6 @@ public class OutriggerServerImpl 
         ProxyPreparer transactionManagerPreparer;
         ProxyPreparer listenerPreparer;
         Exporter exporter;
-        OutriggerServer ourRemoteRef;
         EntryHolderSet contents;
         TransitionWatchers templates;
         OperationJournal operationJournal;
@@ -848,7 +850,7 @@ public class OutriggerServerImpl 
     {
         InitHolder h = new InitHolder();
         h.context = AccessController.getContext();
-        try {
+        
             h.txnMonitor = new TxnMonitor(this, config);
             /* Get the activation related preparers we need */
 
@@ -907,8 +909,6 @@ public class OutriggerServerImpl 
                     activationID);
             }
 
-            h.ourRemoteRef = (OutriggerServer)h.exporter.export(serverGate);
-
             // Create our top level proxy
             h.maxServerQueryTimeout =
                 Config.getLongEntry(config, COMPONENT_NAME, 
@@ -1005,16 +1005,7 @@ public class OutriggerServerImpl 
             h.contentsQueryReaperThread.setPriority(reapingPriority);
             h.contentsQueryReaperThread.setDaemon(true);
             return h;
-        } catch (IOException e) {
-            unwindExporter(h.ourRemoteRef, h.exporter);
-            throw e;
-        } catch (ConfigurationException e){
-            unwindExporter(h.ourRemoteRef, h.exporter);
-            throw e;
-        } catch (ActivationException e){
-            unwindExporter(h.ourRemoteRef, h.exporter);
-            throw e;
-        }
+        
     }
 
     /**
@@ -1469,7 +1460,7 @@ public class OutriggerServerImpl 
      */
      boolean attemptCapture(EntryHandle handle, TransactableMgr txn,
           boolean takeIt, Set lockedEntrySet, 
-	  WeakHashMap provisionallyRemovedEntrySet, long now,
+	  Map provisionallyRemovedEntrySet, long now,
 	  QueryWatcher watcher) 
      {
 	 final EntryHolder holder = contents.holderFor(handle.rep());
@@ -2170,7 +2161,7 @@ public class OutriggerServerImpl 
      * in the passed set.
      */
     private static void waitOnProvisionallyRemovedEntries(
-	    WeakHashMap provisionallyRemovedEntrySet) 
+	    Map provisionallyRemovedEntrySet) 
 	throws InterruptedException
     {
 	if (provisionallyRemovedEntrySet.isEmpty())
@@ -2267,10 +2258,11 @@ public class OutriggerServerImpl 
 
 	EntryHandle handle = null;
 	final Set conflictSet = new java.util.HashSet();
+        // Shared by multiple new objects.
 	final Set lockedEntrySet = 
-	    (ifExists?new java.util.HashSet():null);
-	final WeakHashMap provisionallyRemovedEntrySet = 
-	    new java.util.WeakHashMap();
+	    (ifExists? Collections.newSetFromMap( new ConcurrentHashMap()):null);
+	final Map provisionallyRemovedEntrySet = 
+	    Collections.synchronizedMap(new java.util.WeakHashMap());
 
 	/*
 	 * First we do the straight search
@@ -2502,7 +2494,7 @@ public class OutriggerServerImpl 
      */
     private EntryHandle
 	find(EntryRep tmplRep, Txn txn, boolean takeIt, Set conflictSet, 
-	     Set lockedEntrySet, WeakHashMap provisionallyRemovedEntrySet)
+	     Set lockedEntrySet, Map provisionallyRemovedEntrySet)
 	throws TransactionException
     {
 	final String whichClass = tmplRep.classFor();
@@ -2606,7 +2598,7 @@ public class OutriggerServerImpl 
 	    grant(contentsQuery, leaseTime, contentsLeasePolicy, 
 		  "contentsLeasePolicy");
 
-	contentsQueries.put(uuid, contentsQuery);
+	contentsQueries.put(uuid, contentsQuery); // Very low probability of duplicate.
 	return new MatchSetData(uuid, reps, r.duration);
     }
 
@@ -3633,7 +3625,7 @@ public class OutriggerServerImpl 
 	    tr = new ServerTransaction(mgr, tr.id);
 	    tr.join(participantProxy, crashCount);
 	    txn = txnTable.put(tr);
-        }
+            }
 
         return txn;
     }
@@ -3778,9 +3770,10 @@ public class OutriggerServerImpl 
 	// to a crash after a prepareOp was written but before
 	// a return to the TM
 	//
-	if (txn.getState() == PREPARED)
-	    return PREPARED;
-
+        synchronized (txn){
+            if (txn.getState() == PREPARED)
+                return PREPARED;
+        }
 	/* Make all state changes (in memory and on disk) atomic wrt.
 	 * to operations trying to use the txn.
 	 */
@@ -3919,7 +3912,7 @@ public class OutriggerServerImpl 
      * does not rely on the JDK propagating InteruptException
      * properly.
      */
-    private abstract class Reaper extends Thread {
+    private static abstract class Reaper extends Thread {
 	final private long interval;
 	private boolean dead = false;
 
@@ -4000,22 +3993,36 @@ public class OutriggerServerImpl 
 	     * traverse the data w/o blocking contents 
 	     * call and operations on MatchSet objects
 	     */
-	    ContentsQuery[] queries;
-	    synchronized (contentsQueries) {
-		Collection c = contentsQueries.values();
-		queries = new ContentsQuery[c.size()];
-		queries = (ContentsQuery[])c.toArray(queries);
-	    }
-		    
+//	    ContentsQuery[] queries;
+//	    synchronized (contentsQueries) {
+//		Collection c = contentsQueries.values();
+//		queries = new ContentsQuery[c.size()];
+//		queries = (ContentsQuery[])c.toArray(queries);
+//	    }
+            
+            
+//	    for (int i=0; i< queries.length; i++) {
+//		final ContentsQuery query = queries[i];
+//		synchronized (query) {
+//		    if (query.getExpiration() <= now) {
+//			query.cancel();
+//		    }
+//		}
+//	    }		    
+            
+            /* Do it the modern way */
 	    final long now = System.currentTimeMillis();
-	    for (int i=0; i< queries.length; i++) {
-		final ContentsQuery query = queries[i];
-		synchronized (query) {
-		    if (query.getExpiration() <= now) {
-			query.cancel();
+            Iterator<LeasedResource> it = contentsQueries.values().iterator();
+            while (it.hasNext()){
+                final LeasedResource query = it.next();
+                synchronized(query){
+                    if (query.getExpiration() <= now) {
+			if (query instanceof ContentsQuery ) {
+                            ((ContentsQuery)query).cancel();
+                        }
 		    }
-		}
-	    }
+                }
+            }
 	}
     }
 

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/SingletonQueryWatcher.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/SingletonQueryWatcher.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/SingletonQueryWatcher.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/SingletonQueryWatcher.java Sun Apr 21 07:53:23 2013
@@ -33,19 +33,19 @@ abstract class SingletonQueryWatcher ext
     private volatile boolean resolved = false;
 
     /** If resolved and an entry was found the entry to return */
-    private EntryHandle handle;
+    private volatile EntryHandle handle;
 
     /** 
      * If resolved and an exception needs to be thrown the exception
      * to throw
      */
-    private Throwable toThrow;
+    private volatile Throwable toThrow;
 
     /**
      * The <code>TemplateHandle</code> associated with this
      * watcher.
      */
-    private TemplateHandle owner;
+    private volatile TemplateHandle owner;
 
     /**
      * Create a new <code>SingletonQueryWatcher</code>.
@@ -188,20 +188,20 @@ abstract class SingletonQueryWatcher ext
      *         been resolved.
      */
     void resolve(EntryHandle handle, Throwable throwable) {
-	assert Thread.holdsLock(this) : "Caller of resolve() must hold lock";
-
-	if (resolved)
-	    throw new IllegalStateException(
-		"Can't call resolve on a resolved query ");
-
-	if ((this.handle != null) || (toThrow != null))
-	    throw new IllegalStateException(
-		"At lease one argument must be null");
-
-	resolved = true;
-	this.handle = handle;
-	toThrow = throwable;
-	notifyAll();
+        synchronized (this){
+            if (resolved)
+                throw new IllegalStateException(
+                    "Can't call resolve on a resolved query ");
+
+            if ((this.handle != null) || (toThrow != null))
+                throw new IllegalStateException(
+                    "At lease one argument must be null");
+
+            resolved = true;
+            this.handle = handle;
+            toThrow = throwable;
+            notifyAll();
+        }
     }    
 
     /**
@@ -210,7 +210,9 @@ abstract class SingletonQueryWatcher ext
      * this watcher has not been removed.
      */
     OutriggerServerImpl getServer() {
-	assert Thread.holdsLock(this) : "getServer() called without lock";
+        // reference is volatile, will retrieve current server.
+        // setting of owner wasn't synchronized.
+//	assert Thread.holdsLock(this) : "getServer() called without lock";
 	return owner.getServer();
     }
 }

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/SnapshotRep.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/SnapshotRep.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/SnapshotRep.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/SnapshotRep.java Sun Apr 21 07:53:23 2013
@@ -71,7 +71,7 @@ import net.jini.core.entry.Entry;
 class SnapshotRep implements Entry {
     static final long serialVersionUID = 5126328162389368097L;
 
-    private EntryRep rep;	// the rep from the snapshot
+    private final EntryRep rep;	// the rep from the snapshot
 
     /**
      * Create a new <code>SnapshotRep</code> that is a snapshot of

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/StorableReference.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/StorableReference.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/StorableReference.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/StorableReference.java Sun Apr 21 07:53:23 2013
@@ -38,13 +38,13 @@ import net.jini.security.ProxyPreparer;
  */
 class StorableReference implements Externalizable {
     /** The proxy in marshalled form */
-    private MarshalledObject bytes;
+    private volatile MarshalledObject bytes;
 
     /** A cached copy of the unmarshalled proxy */
-    private transient Object obj;
+    private volatile transient Object obj;
 
     /** True if the <code>obj</code> has been prepared */
-    private transient boolean prepared;
+    private volatile transient boolean prepared;
 
     private static final boolean DEBUG = false;
     private static final long serialVersionUID = -3793675220968988873L;

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TakeIfExistsWatcher.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TakeIfExistsWatcher.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TakeIfExistsWatcher.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TakeIfExistsWatcher.java Sun Apr 21 07:53:23 2013
@@ -17,6 +17,7 @@
  */
 package com.sun.jini.outrigger;
 
+import java.util.Map;
 import java.util.Set;
 import java.util.WeakHashMap;
 import net.jini.core.transaction.TransactionException;
@@ -58,7 +59,7 @@ class TakeIfExistsWatcher extends Single
      * we would have liked to return, but have been provisionally
      * removed.
      */
-    private final WeakHashMap provisionallyRemovedEntrySet;
+    private final Map provisionallyRemovedEntrySet;
 
     /**
      * Create a new <code>TakeIfExistsWatcher</code>.
@@ -89,7 +90,7 @@ class TakeIfExistsWatcher extends Single
      */
     TakeIfExistsWatcher(long expiration, long timestamp, 
 	 long startOrdinal, Set lockedEntries, 
-         WeakHashMap provisionallyRemovedEntrySet, Txn txn)
+         Map provisionallyRemovedEntrySet, Txn txn)
     {
 	super(expiration, timestamp, startOrdinal);
 

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/ThrowThis.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/ThrowThis.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/ThrowThis.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/ThrowThis.java Sun Apr 21 07:53:23 2013
@@ -28,8 +28,8 @@ package com.sun.jini.outrigger;
 class ThrowThis implements java.io.Serializable {
     static final long serialVersionUID = -7432214583908049814L;
 
-    private Long	evID;		// the event ID
-    private Exception	toThrow;	// the exception to throw
+    private final Long	evID;		// the event ID
+    private final Exception	toThrow;	// the exception to throw
 
     ThrowThis(Long evID, Exception toThrow) {
 	this.evID = evID;

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TransactableReadIfExistsWatcher.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TransactableReadIfExistsWatcher.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TransactableReadIfExistsWatcher.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TransactableReadIfExistsWatcher.java Sun Apr 21 07:53:23 2013
@@ -17,6 +17,7 @@
  */
 package com.sun.jini.outrigger;
 
+import java.util.Map;
 import java.util.Set;
 import java.util.WeakHashMap;
 import net.jini.core.transaction.TransactionException;
@@ -58,7 +59,7 @@ class TransactableReadIfExistsWatcher ex
      * we would have liked to return, but have been provisionally
      * removed.
      */
-    private final WeakHashMap provisionallyRemovedEntrySet;
+    private final Map provisionallyRemovedEntrySet;
 
     /**
      * Create a new <code>TransactableReadIfExistsWatcher</code>.
@@ -89,7 +90,7 @@ class TransactableReadIfExistsWatcher ex
      */
     TransactableReadIfExistsWatcher(long expiration, long timestamp, 
 	 long startOrdinal, Set lockedEntries, 
-         WeakHashMap provisionallyRemovedEntrySet, Txn txn)
+         Map provisionallyRemovedEntrySet, Txn txn)
     {
 	super(expiration, timestamp, startOrdinal);
 

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/Txn.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/Txn.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/Txn.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/Txn.java Sun Apr 21 07:53:23 2013
@@ -119,7 +119,7 @@ class Txn implements TransactableMgr, Tr
      * transaction has been aborted with us being told, or
      * null if no such task as been allocated.
      */
-    private TxnMonitorTask	monitorTask;
+    private volatile TxnMonitorTask	monitorTask;
 
     /** Count of number of threads holding a read lock on state */
     private int stateReaders = 0;

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnMonitorTask.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnMonitorTask.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnMonitorTask.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnMonitorTask.java Sun Apr 21 07:53:23 2013
@@ -33,6 +33,8 @@ import java.util.WeakHashMap;
 import java.util.Iterator;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -115,25 +117,25 @@ class TxnMonitorTask extends RetryTask
      * <code>null</code> until we have at least one. Represented by
      * <code>QueryWatcher</code> objects.  
      */
-    private Map		queries;
+    private Map<QueryWatcher,Collection<Txn>>		queries; //Sync on this.
 
     /** count of RemoteExceptions */
-    private int		failCnt;
+    private final AtomicInteger		failCnt;
 
     /** 
      * The next time we need to poll the transaction manager 
      * to get <code>txn</code>'s actual state.
      */
-    private long	nextQuery;
+    private final AtomicLong	nextQuery;
 
     /**
      * When we're given an opportunity to poll the transaction manager
      * for the <code>txn</code>'s state, do so.
      */
-    private boolean	mustQuery;
+    private volatile boolean	mustQuery;
 
     /** next value added to <code>nextQuery</code> */
-    private long	deltaT;
+    private volatile long	deltaT;
 
     /**
      * The initial grace period before the first query.
@@ -168,9 +170,10 @@ class TxnMonitorTask extends RetryTask
 	super(manager, wakeupMgr);
 	this.txn = txn;
 	this.monitor = monitor;
-	nextQuery = startTime();	// retryTime will add INITIAL_GRACE
+	nextQuery = new AtomicLong(startTime());	// retryTime will add INITIAL_GRACE
 	deltaT = INITIAL_GRACE;
 	mustQuery = true;
+        failCnt = new AtomicInteger();
     }
 
     /**
@@ -181,24 +184,31 @@ class TxnMonitorTask extends RetryTask
      * otherwise we back off quickly.
      */
     public long retryTime() {
-	if (failCnt == 0 && txn.getState() != PREPARED) {      // no failures
-	    if (logger.isLoggable(Level.FINEST)) {
-		logger.log(Level.FINEST, "{0} retryTime adds {1}", 
-			   new Object[]{this, Long.valueOf(deltaT)});
-	    }
-
-	    nextQuery += deltaT;
-	    if (deltaT < MAX_DELTA_T)
-		deltaT = Math.min(deltaT * 2, MAX_DELTA_T);
-	} else {
-	    if (logger.isLoggable(Level.FINEST)) {
-		logger.log(Level.FINEST, "{0} retryTime adds {1} (for {2})", 
-			   new Object[]{this, Long.valueOf(BETWEEN_EXCEPTIONS), 
-			       (failCnt != 0 ? "failure" : "PREPARED")});
-	    }
-	    nextQuery += BETWEEN_EXCEPTIONS;
-	}
-	return nextQuery;
+        boolean noFailures = false;
+        synchronized (txn){
+            noFailures = (failCnt.get() == 0 && txn.getState() != PREPARED);
+        }
+            if (noFailures) {      // no failures
+                if (logger.isLoggable(Level.FINEST)) {
+                    logger.log(Level.FINEST, "{0} retryTime adds {1}", 
+                               new Object[]{this, Long.valueOf(deltaT)});
+                }
+
+                nextQuery.addAndGet(deltaT);
+                synchronized (this){
+                    if (deltaT < MAX_DELTA_T)
+                        deltaT = Math.min(deltaT * 2, MAX_DELTA_T);
+                }
+            } else {
+                if (logger.isLoggable(Level.FINEST)) {
+                    logger.log(Level.FINEST, "{0} retryTime adds {1} (for {2})", 
+                               new Object[]{this, Long.valueOf(BETWEEN_EXCEPTIONS), 
+                                   (failCnt.get() != 0 ? "failure" : "PREPARED")});
+                }
+                nextQuery.addAndGet(BETWEEN_EXCEPTIONS);
+            }
+        
+	return nextQuery.get();
     }
 
     /**
@@ -238,7 +248,7 @@ class TxnMonitorTask extends RetryTask
     synchronized void addSibling(Txn txn) {
 	if (queries == null || queries.size() == 0)
 	    return;
-	Collection sibling = Collections.nCopies(1, txn);
+	Collection<Txn> sibling = Collections.nCopies(1, txn);
 	Iterator it = queries.keySet().iterator();
 	while (it.hasNext()) {
 	    QueryWatcher query = (QueryWatcher)it.next();
@@ -265,14 +275,17 @@ class TxnMonitorTask extends RetryTask
 	 */
 	if (attempt() == 0)
 	    return false;
-
+        int txnState;
+        synchronized (txn){
+            txnState = txn.getState();
+        }
 	if (logger.isLoggable(Level.FINEST)) {
 	    logger.log(Level.FINEST, "{0} txn.getState() = {1}", 
-	        new Object[]{this, Integer.valueOf(txn.getState())});
+	        new Object[]{this, Integer.valueOf(txnState)});
 	}
 
 	// not active or prepared == no longer blocking
-	int txnState = txn.getState();
+	
 	if (txnState != ACTIVE && txnState != PREPARED)
 	    return true;
 
@@ -295,7 +308,7 @@ class TxnMonitorTask extends RetryTask
 
 		if (logger.isLoggable(Level.FINEST)) {
 		    logger.log(Level.FINEST, "{0} nextQuery {1}", 
-			       new Object[]{this, Long.valueOf(nextQuery)});
+			       new Object[]{this, nextQuery});
 		}
 
 		while (it.hasNext()) {
@@ -309,7 +322,7 @@ class TxnMonitorTask extends RetryTask
 				       Long.valueOf(query.getExpiration())});
 		    }
 
-		    if (query.getExpiration() < nextQuery || 
+		    if (query.getExpiration() < nextQuery.get() || 
 			query.isResolved())
 			it.remove();	// expired, so we don't care about it
 		    else {
@@ -406,7 +419,7 @@ class TxnMonitorTask extends RetryTask
 	     * be very complicated since we need to hold a lock to
 	     * while reading and acting on the state.
 	     */
-	    if (++failCnt >= MAX_FAILURES) {
+	    if (failCnt.incrementAndGet() >= MAX_FAILURES) {
 		if (logger.isLoggable(Level.INFO)) {
 		    logger.log(Level.INFO, "Got NoSuchObjectException when " +
 			"calling getState on " + tr + ", this was the " +
@@ -424,7 +437,7 @@ class TxnMonitorTask extends RetryTask
 		return false;	       // try again next time
 	    }
 	} catch (RemoteException e) {
-	    if (++failCnt >= MAX_FAILURES) {
+	    if (failCnt.incrementAndGet() >= MAX_FAILURES) {
 		/* abort if we are not prepared and not already 
 		 * aborted. If prepared retry, otherwise
 		 * we're done. Check state and make any abort() call
@@ -451,7 +464,7 @@ class TxnMonitorTask extends RetryTask
 			    throw new AssertionError(ume);
 			}
 		      case PREPARED:
-		        final Level l = (failCnt%MAX_FAILURES == 0)?
+		        final Level l = (failCnt.get()%MAX_FAILURES == 0)?
 			    Level.INFO:Levels.FAILED;
 			if (logger.isLoggable(l)) {
 			    logger.log(l, "Got RemoteException when calling " +
@@ -489,7 +502,7 @@ class TxnMonitorTask extends RetryTask
 		       new Object[]{this, Integer.valueOf(trState)});
 	}
 
-	failCnt = 0;		       // reset failures -- we got a response
+	failCnt.set(0);		       // reset failures -- we got a response
 
 	/*
 	 * If the two states aren't the same, the state changed and we
@@ -552,7 +565,7 @@ class TxnMonitorTask extends RetryTask
      * <code>true</code>.
      */
     synchronized void add(QueryWatcher query) {
-	if (query == null || query.getExpiration() <= nextQuery) {
+	if (query == null || query.getExpiration() <= nextQuery.get()) {
 	    if (logger.isLoggable(Level.FINEST))
 		logger.log(Level.FINEST, "adding resource to task -- SHORT");
 	    mustQuery = true;
@@ -560,7 +573,7 @@ class TxnMonitorTask extends RetryTask
 	    if (logger.isLoggable(Level.FINEST))
 		logger.log(Level.FINEST, "adding resource to task -- LONG");
 	    if (queries == null)
-		queries = new WeakHashMap();// we use it like a WeakHashSet
+		queries = new WeakHashMap<QueryWatcher,Collection<Txn>>();// we use it like a WeakHashSet
 	    queries.put(query, null);
 	}
     }

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnState.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnState.java?rev=1470272&r1=1470271&r2=1470272&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnState.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnState.java Sun Apr 21 07:53:23 2013
@@ -43,13 +43,13 @@ class TxnState {
      * direct reference to the only manager for this handle, or a reference
      * to an <code>HashSet</code> with entries for each associated manager.
      */
-    private Object		mgrs;
+    private volatile Object		mgrs;
 
     /**
      * The current state of the handle, such as <code>READ</code> or
      * <code>TAKE</code>.
      */
-    private int			state;
+    private volatile int			state;
 
     /**
      * The holder the handle which owns this object is in



Mime
View raw message