river-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Trasuk <tras...@stratuscom.com>
Subject Re: svn commit: r1554723 [1/5] - in /river/jtsk/skunk/qa_refactor/trunk: qa/src/com/sun/jini/qa/harness/ qa/src/com/sun/jini/test/impl/mahalo/ qa/src/com/sun/jini/test/impl/reggie/ qa/src/com/sun/jini/test/resources/ qa/src/com/sun/jini/test/share/ qa/src/...
Date Thu, 02 Jan 2014 18:35:33 GMT

Questions interleaved…

Greg.

On Jan 1, 2014, at 9:45 PM, peter_firmstone@apache.org wrote:

> Author: peter_firmstone
> Date: Thu Jan  2 02:45:07 2014
> New Revision: 1554723
> 
> URL: http://svn.apache.org/r1554723
> Log:
> Cleaned up synchronization and locking strategies and removed instances of synchronization while performing remote calls.
> 
> Changed final fields to non final where "this" escaped during construction.
> 
> Replaced TaskManager with ExecutorService where Task.runAfter was not required, TaskManager is still utilised by JoinManager, ServiceDiscoveryManager and the qa test framework.
> Changed TaskManager to accept Runnable and to check for Task instances.
> 

What’s the purpose behind this?  Is there a problem with TaskManager?  If so, wouldn’t the risk surface be minimized by fixing TaskManager or re-implementing it with the concurrent library, rather than changing all the classes where TaskManager is used?

> Changed RetryTask, pushed TaskManager.Task implementations to subclasses that used it.  RetryTask is not compatible with Task.runAfter as documented in River-344.
> 
> Added Generics to static configuration methods, to eliminate casts.
> 

Is that a change to the API of Configuration?  If so, it should be discussed (although I realize that you’re experimenting in qa_refactor, one assumes you’ll want to merge back into trunk at some point, so you may as well start the discussion now).

> Started working on ScheduledExecutors to take advantage of a ScheduledExecutorService to allow sharing of a thread pool for tasks that have dependencies, require order and must not execute until their dependencies have completed.
> 

Isn’t that what TaskManager does?

> Added:
>    river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/impl/thread/SynchronousExecutors.java
>    river/jtsk/skunk/qa_refactor/trunk/test/src/org/apache/river/impl/thread/
>    river/jtsk/skunk/qa_refactor/trunk/test/src/org/apache/river/impl/thread/SynchronouExecutorsTest.java
> Modified:
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/MasterHarness.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/MasterTest.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/NonActivatableGroupImpl.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTask.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/reggie/MultihomedClientTest.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/resources/qa1.logging
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/resources/qa1_debug.logging
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/BaseQATest.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LookupServices.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/DiscardUnreachable.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/GroupsMulticastMonitorReplace.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorChange.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorReplace.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorReplaceNone.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorStop.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorTerminate.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/RemoveGroupsSome.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/SetGroupsReplaceSome.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/joinmanager/Register.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/joinmanager/RegisterAttributes.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/locatordiscovery/DiscardUnreachable.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/ConstructorDups.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/DiscardUnreachable.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorChange.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorReplace.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorStop.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorStopReplace.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorTerminate.java
>    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/renewalmanager/LocalLease.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/config/Config.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/fiddler/FiddlerImpl.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/fiddler/FiddlerInit.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/AbortJob.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/CommitJob.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/Job.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/ParticipantTask.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/PrepareAndCommitJob.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/PrepareJob.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mahalo/SettlerTask.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/mercury/MailboxImpl.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/norm/NormServerBaseImpl.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/norm/event/EventType.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/norm/event/EventTypeGenerator.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/Notifier.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnMonitor.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/outrigger/TxnMonitorTask.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/RetryTask.java
>    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/TaskManager.java
>    river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/AbstractLookupDiscovery.java
>    river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/AbstractLookupDiscoveryManager.java
>    river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/AbstractLookupLocatorDiscovery.java
>    river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/LookupLocatorDiscovery.java
>    river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lease/LeaseRenewalManager.java
>    river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/JoinManager.java
>    river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/MasterHarness.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/MasterHarness.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/MasterHarness.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/MasterHarness.java Thu Jan  2 02:45:07 2014
> @@ -211,7 +211,7 @@ class MasterHarness {
> 	}
> 	config = new QAConfig(args);
> 	keepaliveThread = new Thread(new KeepAlivePort(), "Keepalive");
> -	keepaliveThread.setDaemon(true);
> +	keepaliveThread.setDaemon(false);
> 	keepaliveThread.start();
> 	try {
> 	    Thread.sleep(1000);
> @@ -224,7 +224,7 @@ class MasterHarness {
> 		Class.forName("com.sun.jini.qa.harness.MergedPolicyProvider");
> 	    if (policyClass.getClassLoader().getParent() != null) {
> 		outStream.println("MergedPolicyprovider must be "
> -				+ "installed in an extensions directory");
> +				+ "installed in an extensions ClassLoader");
> 		System.exit(1);
> 	    }
> 	} catch (Exception e) {
> @@ -249,10 +249,11 @@ class MasterHarness {
>     private class KeepAlivePort implements Runnable {
> 
> 	public void run() {
> +            ServerSocket socket = null;
> 	    ArrayList socketList = new ArrayList(); // keep references
> 	    try {
>                 SocketAddress add = new InetSocketAddress(KEEPALIVE_PORT);
> -		ServerSocket socket = new ServerSocket();
> +		socket = new ServerSocket();
> //                if (!socket.getReuseAddress()) socket.setReuseAddress(true);
>                 socket.bind(add);
> 		while (true) {
> @@ -262,8 +263,12 @@ class MasterHarness {
> 		outStream.println("Problem with KEEPALIVE_PORT:" + KEEPALIVE_PORT );
> 		outStream.println("Unexpected exception:");
> 		e.printStackTrace(outStream);
> +	    } finally {
> +                try {
> +                    socket.close();
> +                } catch (IOException ex) {/*Ignore*/}
> 		System.exit(1);
> -	    }
> +            }
> 	}
>     }
> 
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/MasterTest.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/MasterTest.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/MasterTest.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/MasterTest.java Thu Jan  2 02:45:07 2014
> @@ -347,9 +347,9 @@ class MasterTest {
>     private static class AutotRequestHandler implements Runnable {
> 
> 	public void run() {
> +            ServerSocket socket = null;
> 	    try {
> -		ServerSocket socket = 
> -		    new ServerSocket(InboundAutotRequest.PORT);
> +		socket = new ServerSocket(InboundAutotRequest.PORT);
> 		while (true) {
> 		    Socket requestSocket = socket.accept();
> 		    logger.log(Level.FINER, "Got an external request");
> @@ -374,7 +374,11 @@ class MasterTest {
> 		}
> 	    } catch (Throwable e) {
> 		logger.log(Level.SEVERE, "Unexpected exception", e);
> -	    }
> +	    } finally {
> +                try {
> +                    socket.close();
> +                } catch (IOException ex) {/*Ignore*/}
> +            }
> 	}
>     }
> }
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/NonActivatableGroupImpl.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/NonActivatableGroupImpl.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/NonActivatableGroupImpl.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/NonActivatableGroupImpl.java Thu Jan  2 02:45:07 2014
> @@ -94,10 +94,10 @@ class NonActivatableGroupImpl {
> 	private Object proxy;
> 
> 	/** the groups exporter */
> -	private final Exporter exporter;
> +	private Exporter exporter;
> 
> 	/** store service references here to ensure no GC interference */
> -	private final ArrayList serviceList = new ArrayList();
> +	private ArrayList serviceList = new ArrayList();
> 
> 	/**
> 	 * Construct a <code>NonActivatableGroup</code>. Instances export themselves
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTask.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTask.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTask.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/mahalo/RandomStressTask.java Thu Jan  2 02:45:07 2014
> @@ -27,12 +27,13 @@ import java.rmi.*;
> import com.sun.jini.test.share.TestParticipant;
> import com.sun.jini.test.share.TxnManagerTestOpcodes;
> import com.sun.jini.test.share.TxnTestUtils;
> +import com.sun.jini.thread.TaskManager.Task;
> 
> 
> /**
>  */
> public abstract class RandomStressTask extends RetryTask
> -        implements TxnManagerTestOpcodes {
> +        implements TxnManagerTestOpcodes, Task {
>     private static final boolean DEBUG = false;
>     private TransactionManager mgr;
>     protected Transaction.Created cr;
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/reggie/MultihomedClientTest.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/reggie/MultihomedClientTest.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/reggie/MultihomedClientTest.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/impl/reggie/MultihomedClientTest.java Thu Jan  2 02:45:07 2014
> @@ -32,7 +32,7 @@ import java.io.PrintStream;
>  * 
>  */
> public class MultihomedClientTest implements LegacyTest {
> -
> +    
>     private String command = System.getProperty("java.home") + File.separator
>         + "bin" + File.separator + "java ";
>     private QAConfig config = null;
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/resources/qa1.logging
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/resources/qa1.logging?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/resources/qa1.logging (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/resources/qa1.logging Thu Jan  2 02:45:07 2014
> @@ -39,7 +39,7 @@ handlers = java.util.logging.ConsoleHand
> # level setting (set below) to limit messages printed to
> # the console.
> 
> -.level = INFO
> +.level = FINE
> 
> ############################################################
> # Handler specific properties: formatters and logger levels
> @@ -105,7 +105,7 @@ java.util.logging.FileHandler.level = IN
> 
> # For Everything
> sun.rmi.level = CONFIG
> -net.jini.level = CONFIG
> +net.jini.level = FINE
> org.apache.river.level = CONFIG
> com.sun.jini.level = CONFIG
> 
> @@ -184,9 +184,9 @@ com.sun.jini.discovery.level = SEVERE
> # For the Helper Utilities
> net.jini.discovery.LookupDiscovery.level = SEVERE
> net.jini.discovery.LookupLocatorDiscovery.level = SEVERE
> -net.jini.lookup.JoinManager.level = SEVERE
> +net.jini.lookup.JoinManager.level = FINE
> net.jini.lookup.ServiceDiscoveryManager.level = SEVERE
> -net.jini.lease.LeaseRenewalManager.level = SEVERE
> +net.jini.lease.LeaseRenewalManager.level = FINEST
> 
> # For Thread Pool Utilities
> com.sun.jini.thread.RetryTask.level = SEVERE
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/resources/qa1_debug.logging
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/resources/qa1_debug.logging?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/resources/qa1_debug.logging (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/resources/qa1_debug.logging Thu Jan  2 02:45:07 2014
> @@ -39,7 +39,7 @@ handlers = java.util.logging.ConsoleHand
> # level setting (set below) to limit messages printed to
> # the console.
> 
> -.level = INFO
> +.level = FINE
> 
> ############################################################
> # Handler specific properties: formatters and logger levels
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/BaseQATest.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/BaseQATest.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/BaseQATest.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/BaseQATest.java Thu Jan  2 02:45:07 2014
> @@ -41,15 +41,21 @@ import net.jini.core.lookup.ServiceRegis
> 
> 
> import java.util.ArrayList;
> +import java.util.Arrays;
> import java.util.Collection;
> import java.util.HashMap;
> import java.util.HashSet;
> import java.util.Iterator;
> +import java.util.LinkedList;
> import java.util.List;
> import java.util.Map;
> import java.util.Properties;
> import java.util.Set;
> import java.util.concurrent.CopyOnWriteArrayList;
> +import java.util.concurrent.TimeUnit;
> +import java.util.concurrent.locks.Condition;
> +import java.util.concurrent.locks.Lock;
> +import java.util.concurrent.locks.ReentrantLock;
> import java.util.logging.Level;
> 
> /**
> @@ -211,10 +217,21 @@ abstract public class BaseQATest extends
>     public static class LocatorGroupsPair {
>         private final LookupLocator locator;
>         private final String[]      groups;
> +        private final int hash;
>         public LocatorGroupsPair(LookupLocator locator, String[] groups) {
>             this.locator = locator;
>             this.groups  = groups;
> +            int hash = 7;
> +            hash = 89 * hash + (this.locator != null ? this.locator.hashCode() : 0);
> +            hash = 89 * hash + Arrays.deepHashCode(this.groups);
> +            this.hash = hash;
>         }//end constructor
> +
> +        @Override
> +        public int hashCode() {
> +            return hash;
> +        }
> +        
>         public boolean equals(Object obj) {
>             if(this == obj) return true;
>             if( !(obj instanceof LocatorGroupsPair) ) return false;
> @@ -278,19 +295,30 @@ abstract public class BaseQATest extends
>      *  not to proceed.
>      */
>     protected class LookupListener implements DiscoveryListener {
> -        public LookupListener(){ }
> -        private final Map<LookupLocator,String[]> discoveredMap = new HashMap<LookupLocator,String[]>(11);
> -        private final Map<LookupLocator,String[]> discardedMap  = new HashMap<LookupLocator,String[]>(11);
> -
> -        private final Map<LookupLocator,String[]> expectedDiscoveredMap = new HashMap<LookupLocator,String[]>(11);
> -        private final Map<LookupLocator,String[]> expectedDiscardedMap  = new HashMap<LookupLocator,String[]>(11);
> +        
> +        public final Lock lock;
> +        public final Condition discovered;
> +        public final Condition discarded;
> +        private final Map<LookupLocator,String[]> discoveredMap;
> +        private final Map<LookupLocator,String[]> discardedMap;
> +
> +        private final Map<LookupLocator,String[]> expectedDiscoveredMap;
> +        private final Map<LookupLocator,String[]> expectedDiscardedMap;
> +        public LookupListener(){
> +            lock = new ReentrantLock();
> +            discovered = lock.newCondition();
> +            discarded = lock.newCondition();
> +            discoveredMap = new HashMap<LookupLocator,String[]>(11);
> +            discardedMap  = new HashMap<LookupLocator,String[]>(11);
> +            expectedDiscoveredMap = new HashMap<LookupLocator,String[]>(11);
> +            expectedDiscardedMap  = new HashMap<LookupLocator,String[]>(11);
> +        }
> +        
> 
>         Set<Map.Entry<LookupLocator,String[]>> getDiscovered(){
> -            synchronized(this){
>                 Set<Map.Entry<LookupLocator,String[]>> disc = new HashSet<Map.Entry<LookupLocator,String[]>>(discoveredMap.size());
>                 disc.addAll(discoveredMap.entrySet());
>                 return disc;
> -            }
>         }
> 
>         /**
> @@ -301,17 +329,13 @@ abstract public class BaseQATest extends
>          * @return 
>          */
>         void updateDiscovered(LookupLocator l, String[] groups){
> -            synchronized(this){
>                 discardedMap.remove(l);
>                 discoveredMap.put(l, groups);
> -                this.notifyAll();
> -            }
> +                discovered.signalAll();
>         }
> 
>         int discoveredCount(){
> -            synchronized(this){
>                 return discoveredMap.size();
> -            }
>         }
> 
>         /** Returns the locators of the lookups from discoveredMap, which
> @@ -319,11 +343,14 @@ abstract public class BaseQATest extends
>          *  as well as the lookups that have already been discovered.
>          */
>         public LookupLocator[] getDiscoveredLocators() {
> -            synchronized(this) {
> +            lock.lock();
> +            try {
>                 Set kSet = discoveredMap.keySet();
>                 return ((LookupLocator[])(kSet).toArray
>                                             (new LookupLocator[kSet.size()]));
> -            }//end sync(this)
> +            } finally {
> +                lock.unlock();
> +            }
>         }//end getDiscoveredLocators
> 
>         /** Returns the locators that are expected to be discovered, but which
> @@ -335,7 +362,8 @@ abstract public class BaseQATest extends
>          *  have not yet been discovered.
>          */
>         public LookupLocator[] getUndiscoveredLocators() {
> -            synchronized(this) {
> +            lock.lock();
> +            try {
>                 Set dSet = discoveredMap.keySet();
>                 Set eSet = expectedDiscoveredMap.keySet();
>                 ArrayList uLocsList = new ArrayList(eSet.size());
> @@ -346,46 +374,61 @@ abstract public class BaseQATest extends
>                 }//end loop
>                 return ((LookupLocator[])(uLocsList).toArray
>                                        (new LookupLocator[uLocsList.size()]));
> -            }//end sync(this)
> +            } finally {
> +                lock.unlock();
> +            }
>         }//end getUndiscoveredLocators
> 
>         public void clearAllEventInfo() {
> -            synchronized(this) {
> +            lock.lock();
> +            try {
>                 discoveredMap.clear();
>                 discardedMap.clear();
>                 expectedDiscoveredMap.clear();
>                 expectedDiscardedMap.clear();
> -            }//end sync(this)
> +            } finally {
> +                lock.unlock();
> +            }
>         }//end clearAllEventInfo
> 
>         public void clearDiscoveryEventInfo() {
> -            synchronized(this) {
> +            lock.lock();
> +            try {
>                 discoveredMap.clear();
>                 expectedDiscoveredMap.clear();
> -            }//end sync(this)
> +            } finally {
> +                lock.unlock();
> +            }
>         }//end clearDiscoveryEventInfo
> 
>         public void clearDiscardEventInfo() {
> -            synchronized(this) {
> +            lock.lock();
> +            try {
>                 discardedMap.clear();
>                 expectedDiscardedMap.clear();
> -            }//end sync(this)
> +            } finally {
> +                lock.unlock();
> +            }
>         }//end clearDiscardEventInfo
> 
>         /** Use this method to set the contents of the discoveredMap to a
>          *  specific set of values.
>          */
>         public void setDiscoveredMap(List locGroupsList) {
> -            synchronized(this) {
> +            Iterator it = locGroupsList.iterator();
> +            lock.lock();
> +            try {
>                 discoveredMap.clear();
>                 discardedMap.clear();
> -                for(int i=0;i<locGroupsList.size();i++) {
> -                    LocatorGroupsPair pair =
> -                                      (LocatorGroupsPair)locGroupsList.get(i);
> +                while (it.hasNext()) {
> +                    LocatorGroupsPair pair = (LocatorGroupsPair)it.next();
>                     discoveredMap.put(pair.getLocator(), pair.getGroups());
>                 }//end loop
> -                this.notifyAll();
> -            }//end sync(this)
> +                discovered.signalAll();
> +                discarded.signalAll();
> +            } finally {
> +                lock.unlock();
> +            }
>         }//end setDiscoveredMap
> 
>         /** Use this method to set the contents of both the discoveredMap
> @@ -393,23 +436,25 @@ abstract public class BaseQATest extends
>          * @param locGroupsList list containing LocatorGroupsPair to be set.
>          */
>         public void setDiscardEventInfo(List<LocatorGroupsPair> locGroupsList) {
> -            synchronized(this) {
> +            Iterator<LocatorGroupsPair> it = locGroupsList.iterator();
> +            lock.lock();
> +            try {
>                 discoveredMap.clear();
>                 discardedMap.clear();
> -                synchronized (locGroupsList){
> -                    int l = locGroupsList.size();
> -                    for(int i=0;i<l;i++) {
> -                        LocatorGroupsPair pair = locGroupsList.get(i);
> -                        /* Have to set discoveredMap so that discarded() method
> -                         * will place discarded lookup in the discardedMap when
> -                         * the discarded event arrives.
> -                         */
> -                        discoveredMap.put(pair.getLocator(), pair.getGroups());
> -                        expectedDiscardedMap.put(pair.getLocator(), pair.getGroups());
> -                    }//end loop
> +                while (it.hasNext()){
> +                    LocatorGroupsPair pair = it.next();
> +                    /* Have to set discoveredMap so that discarded() method
> +                     * will place discarded lookup in the discardedMap when
> +                     * the discarded event arrives.
> +                     */
> +                    discoveredMap.put(pair.getLocator(), pair.getGroups());
> +                    expectedDiscardedMap.put(pair.getLocator(), pair.getGroups());
>                 }
> -                this.notifyAll();
> -            }//end sync(this)
> +                discovered.signalAll();
> +                discarded.signalAll();
> +            } finally {
> +                lock.unlock();
> +            }
>         }//end clearDiscardEventInfo
> 
>         /** This method should be called whenever the lookups this listener
> @@ -444,40 +489,38 @@ abstract public class BaseQATest extends
>                                          LookupLocator[] locatorsToDiscover,
>                                          String[] groupsToDiscover)
>         {
> -            synchronized(this) {
> -                LookupLocator[] locators = toLocatorArray(locGroupsList);
> -                boolean discoverAll = discoverAllLookups(locGroupsList,
> -                                                   groupsToDiscover);
> -                /* The input ArrayList contains (locator,groups) pairs that
> -                 * represent the locator and current member groups of lookup
> -                 * services that have been started. Those lookup services 
> -                 * that satisfy one or both of the following conditions
> -                 * either are expected to be discovered, or have already been
> -                 * discovered:
> -                 *   - the lookup's corresponding locator is referenced in the
> -                 *     locatorsToDiscover parameter
> -                 *   - the lookup's current member groups consist of one or
> -                 *     more of the groups referenced in the groupsToDiscover
> -                 *     parameter
> -                 * The (locator,groups) pairs from the ArrayList that
> -                 * correspond to such lookup services are placed in the set
> -                 * that contains information related to the lookup services
> -                 * that are expected to be discovered.
> -                 */
> -                synchronized (locGroupsList){
> -                    int l = locGroupsList.size();
> -                    for(int i=0;i<l;i++) {
> -                        LocatorGroupsPair pair =
> -                                          (LocatorGroupsPair)locGroupsList.get(i);
> -                        LookupLocator curLoc    = pair.getLocator();
> -                        String[]      curGroups = pair.getGroups();
> -                        if(    discoverByLocators(curLoc,locatorsToDiscover)
> -                            || discoverAll
> -                            || discoverByGroups(curGroups,groupsToDiscover) )
> -                        {
> -                            expectedDiscoveredMap.put(curLoc,curGroups);
> -                        }//endif
> -                    }//end loop
> +            LookupLocator[] locators = toLocatorArray(locGroupsList);
> +            boolean discoverAll = discoverAllLookups(locGroupsList,
> +                                               groupsToDiscover);
> +            /* The input ArrayList contains (locator,groups) pairs that
> +             * represent the locator and current member groups of lookup
> +             * services that have been started. Those lookup services 
> +             * that satisfy one or both of the following conditions
> +             * either are expected to be discovered, or have already been
> +             * discovered:
> +             *   - the lookup's corresponding locator is referenced in the
> +             *     locatorsToDiscover parameter
> +             *   - the lookup's current member groups consist of one or
> +             *     more of the groups referenced in the groupsToDiscover
> +             *     parameter
> +             * The (locator,groups) pairs from the ArrayList that
> +             * correspond to such lookup services are placed in the set
> +             * that contains information related to the lookup services
> +             * that are expected to be discovered.
> +             */
> +            Iterator it = locGroupsList.iterator();
> +            lock.lock();
> +            try {
> +                while (it.hasNext()){
> +                    LocatorGroupsPair pair = (LocatorGroupsPair)it.next();
> +                    LookupLocator curLoc    = pair.getLocator();
> +                    String[]      curGroups = pair.getGroups();
> +                    if(    discoverByLocators(curLoc,locatorsToDiscover)
> +                        || discoverAll
> +                        || discoverByGroups(curGroups,groupsToDiscover) )
> +                    {
> +                        expectedDiscoveredMap.put(curLoc,curGroups);
> +                    }//endif
>                 }
>                 /* The input ArrayList contains (locator,groups) pairs that
>                  * represent the locator and current member groups of lookup
> @@ -681,7 +724,9 @@ abstract public class BaseQATest extends
>                     expectedDiscardedMap.remove(loc);
>                     expectedDiscoveredMap.put(loc,memberGroups);
>                 }//end loop
> -            }//end sync(this)
> +            } finally {
> +                lock.unlock();
> +            }
>         }//end setLookupsToDiscover
> 
> //        /** Returns all of the groups (duplicates removed), across all lookup
> @@ -710,7 +755,8 @@ abstract public class BaseQATest extends
>                 logger.log(Level.FINE, " discovery event received "
>                                   +"-- "+regs.length+" lookup(s)");
>                 Map groupsMap = evnt.getGroups();
> -                synchronized(this) {
> +                lock.lock();
> +                try{ 
>                     boolean oneDiscovered = false;
>                     List<ServiceRegistrar> lusList = getLookupListSnapshot
>                                      ("BaseQATest$LookupListenter.discovered");
> @@ -797,7 +843,9 @@ abstract public class BaseQATest extends
>                               " number of currently discovered lookup(s) = "
>                               +discoveredMap.size());
>                     }
> -                }//end sync(this)
> +                } finally {
> +                    lock.unlock();
> +                }
>             } else {//(regs == null)
>                 logger.log(Level.FINE, " discovery event received "
>                                   +"-- event.getRegistrars() returned NULL");
> @@ -811,8 +859,10 @@ abstract public class BaseQATest extends
>                 logger.log(Level.FINE, " discard event received "
>                                   +"-- "+regs.length+" lookup(s)");
>                 Map groupsMap = evnt.getGroups();
> -                synchronized(this) {
> -                    for(int i=0;i<regs.length;i++) {
> +                lock.lock();
> +                try {
> +                    int len = regs.length;
> +                    for(int i=0;i<len;i++) {
>                         /* Can't make a remote call to retrieve the locator
>                          * of the discarded registrar like what was done when
>                          * the registrar was discovered (since it may be down) 
> @@ -838,8 +888,10 @@ abstract public class BaseQATest extends
>                     logger.log(Level.FINE,
>                               " number of currently discovered lookup(s) = "
>                               +discoveredMap.size());
> -                    this.notifyAll();
> -                }//end sync(this)
> +                    discarded.signalAll();
> +                } finally {
> +                    lock.unlock();
> +                }
>             } else {//(regs == null)
>                 logger.log(Level.FINE, " discard event received "
>                                   +"-- event.getRegistrars() returned NULL");
> @@ -860,24 +912,34 @@ abstract public class BaseQATest extends
>     protected class GroupChangeListener extends LookupListener
>                                         implements DiscoveryChangeListener
>     {
> -        public GroupChangeListener(){ }
> -
> -        private final Map<LookupLocator,String[]> changedMap = new HashMap<LookupLocator,String[]>(11);
> -        private final Map<LookupLocator,String[]> expectedChangedMap = new HashMap<LookupLocator,String[]>(11);
> +        private final Map<LookupLocator,String[]> changedMap;
> +        private final Map<LookupLocator,String[]> expectedChangedMap;
> +        private final Condition changed;
> +        public GroupChangeListener(){
> +            changed = lock.newCondition();
> +            changedMap = new HashMap<LookupLocator,String[]>(11);
> +            expectedChangedMap = new HashMap<LookupLocator,String[]>(11);
> +        }
> 
>         public void clearAllEventInfo() {
> -            synchronized(this) {
> +            lock.lock();
> +            try {
>                 super.clearAllEventInfo();
>                 changedMap.clear();
>                 expectedChangedMap.clear();
> -            }//end sync(this)
> +            } finally {
> +                lock.unlock();
> +            }
>         }//end clearAllEventInfo
> 
>         public void clearChangeEventInfo() {
> -            synchronized(this) {
> +            lock.lock();
> +            try {
>                 changedMap.clear();
>                 expectedChangedMap.clear();
> -            }//end sync(this)
> +            } finally {
> +                lock.unlock();
> +            }
>         }//end clearChangeEventInfo
> 
>         /** This method should be called whenever the lookups this listener
> @@ -903,7 +965,8 @@ abstract public class BaseQATest extends
>                                          LookupLocator[] locatorsToDiscover,
>                                          String[] groupsToDiscover)
>         {
> -            synchronized(this) {
> +            lock.lock();
> +            try {
>                 super.setLookupsToDiscover(locGroupsList,
>                                            locatorsToDiscover,
>                                            groupsToDiscover);
> @@ -987,7 +1050,9 @@ abstract public class BaseQATest extends
>                         continue;
>                     }//endif(discoveredByGroup)
>                 }//end loop
> -            }//end sync(this)
> +            } finally {
> +                lock.unlock();
> +            }
>         }//end setLookupsToDiscover
> 
>         public void changed(DiscoveryEvent evnt) {
> @@ -997,7 +1062,8 @@ abstract public class BaseQATest extends
>                 logger.log(Level.FINE, " change event received "
>                                   +"-- "+regs.length+" lookup(s)");
>                 Map groupsMap = evnt.getGroups();
> -                synchronized(this) {
> +                lock.lock();
> +                try {
>                     boolean oneChanged = false;
>                     List<ServiceRegistrar> regList = getLookupListSnapshot
>                                         ("BaseQATest$LookupListenter.changed");
> @@ -1032,8 +1098,10 @@ abstract public class BaseQATest extends
>                                " number of currently discovered lookup(s) = "
>                                +discoveredCount());
>                     }
> -                    this.notifyAll();
> -                }//end sync(this)
> +                    changed.signalAll();
> +                } finally {
> +                    lock.unlock();
> +                }
>             } else {//(regs == null)
>                 logger.log(Level.FINE, " change event received "
>                                   +"-- event.getRegistrars() returned NULL");
> @@ -1180,15 +1248,13 @@ abstract public class BaseQATest extends
>      *  containing instances of <code>LocatorGroupsPair</code>.
>      */
>     public static LookupLocator[] toLocatorArray(List list) {
> -        synchronized (list){
> -            int l = list.size();
> -            LookupLocator[] locArray = new LookupLocator[l];
> -            for(int i=0;i<l;i++) {
> -                LocatorGroupsPair pair = (LocatorGroupsPair)list.get(i);
> -                locArray[i] = pair.getLocator();
> -            }//end loop
> -            return locArray;
> +        Iterator it = list.iterator();
> +        List<LookupLocator> locators = new LinkedList<LookupLocator>();
> +        while (it.hasNext()){
> +            LocatorGroupsPair pair = (LocatorGroupsPair) it.next();
> +            locators.add(pair.getLocator());
>         }
> +        return locators.toArray(new LookupLocator[locators.size()]);
>     }//end toLocatorArray
> 
>     /** Returns an array of group names in which each element of the
> @@ -1301,16 +1367,14 @@ abstract public class BaseQATest extends
>          * groups to discover, then we do not want to discover all of the
>          * lookups
>          */
> -        synchronized (list){
> -            int l = list.size();
> -            for(int i=0;i<l;i++) {
> -                LocatorGroupsPair pair = (LocatorGroupsPair)list.get(i);
> -                String[] curMemberGroups = pair.getGroups();
> -                if( !discoverByGroups(curMemberGroups,groupsToDiscover) ) {
> -                    return false;
> -                }//endif
> -            }//end loop
> -        }
> +        int l = list.size();
> +        for(int i=0;i<l;i++) {
> +            LocatorGroupsPair pair = (LocatorGroupsPair)list.get(i);
> +            String[] curMemberGroups = pair.getGroups();
> +            if( !discoverByGroups(curMemberGroups,groupsToDiscover) ) {
> +                return false;
> +            }//endif
> +        }//end loop
>         return true;
>     }//end discoverAllLookups
> 
> @@ -1543,9 +1607,13 @@ abstract public class BaseQATest extends
>         boolean discoveryComplete = false;
>         boolean showCompInfo = true;//turn this off after 1st pass thru loop
> 	Map discoveredClone = null;
> -        synchronized (listener){
> +        long milliSecondsToWait = nSecsToWait1*1000;
> +        long duration = 0L;
> +        long startTime = System.currentTimeMillis();
> +        listener.lock.lock();
> +        try {
>         iLoop:
> -            for(int i=0;i<nSecsToWait1;i++) {
> +            while(duration<milliSecondsToWait) {
>                 Map discoveredMap = listener.discoveredMap;
>                 Map expectedDiscoveredMap = listener.expectedDiscoveredMap;
> 
> @@ -1605,7 +1673,7 @@ abstract public class BaseQATest extends
>                 }//endif(displayOn)
>                 /* nEventsReceived == nEventsExpected for this listener? */
>                 if(discoveredMap.size() == expectedDiscoveredMap.size()) {
> -                    if(i == (nSecsToWait1-1)) {
> +                    if( (milliSecondsToWait -1000L < duration) && (duration < milliSecondsToWait)) {
>                         logger.log(Level.FINE,
>                                "   events expected ("
>                                +expectedDiscoveredMap.size()+") == events "
> @@ -1623,13 +1691,13 @@ abstract public class BaseQATest extends
>                         discoveryComplete = true;
>                         break iLoop;
>                     } else {
> -                        if(i == (nSecsToWait1-1)) {
> +                        if((milliSecondsToWait -1000L < duration) && (duration < milliSecondsToWait)) {
>                             logger.log(Level.FINE,
>                                               "   not all lookups equal");
>                         }//endif
>                     }//endif
>                 } else {//(nEventsReceived != nEventsExpected)
> -                    if(i == (nSecsToWait1-1)) {
> +                    if((milliSecondsToWait -1000L < duration) && (duration < milliSecondsToWait)) {
>                         logger.log(Level.FINE,
>                                               "   events expected ("
>                                               +expectedDiscoveredMap.size()
> @@ -1638,13 +1706,8 @@ abstract public class BaseQATest extends
>                     }//endif
>                 }//endif(nEventsReceived == nEventsExpected)
>                 try {
> -                    long startTime = System.currentTimeMillis();
> -                    long finishTime = startTime + 1000;
> -                    long remain = 1000;
> -                    do {
> -                        listener.wait(remain); // Wait for discovery for 1000 ms.
> -                        remain = finishTime - System.currentTimeMillis();
> -                    } while (remain > 0); //To avoid spurious wakeup
> +                    listener.discovered.await(1000L, TimeUnit.MILLISECONDS); // Wait for discovery for 1000 ms.
> +                    duration = System.currentTimeMillis() - startTime;
>                 } catch (InterruptedException ex) {
>                     throw new TestException("Interrupted while waiting for discovery", ex);
>                 }
> @@ -1652,9 +1715,12 @@ abstract public class BaseQATest extends
>                 showCompInfo = false;//display comparison info only when i = 0
>             }//end loop(iLoop)
> 
> -        }//end sync(listener)
> +        } finally {
> +            listener.lock.unlock();
> +        }
>         logger.log(Level.FINE, " DISCOVERY wait period complete");
> -        synchronized(listener) {
> +        listener.lock.lock();
> +        try {
>             if(!discoveryComplete) {
>                 throw new TestException("discovery failed -- "
>                                          +"waited "+nSecsToWait1
> @@ -1670,9 +1736,11 @@ abstract public class BaseQATest extends
>                               +" discovery event(s) expected, "
>                               +listener.discoveredMap.size()
>                               +" discovery event(s) received");
> +        } finally {
> +            listener.lock.unlock();
> +        }
> 
>     }//end waitForDiscovery
> -    } // end sync (listener)
>     /** Common code shared by each test that needs to wait for discarded
>      *  events from the discovery helper utility, and verify that the
>      *  expected discarded events have indeed arrived.
> @@ -1707,7 +1775,8 @@ abstract public class BaseQATest extends
>         boolean discardComplete = false;
>         boolean showCompInfo = true;//turn this off after 1st pass thru loop
> 	Map discardedClone = null;
> -        synchronized (listener){
> +        listener.lock.lock();
> +        try {
>             iLoop:
>             for(int i=0;i<nSecsToWait1;i++) {
>                 Map discardedMap = listener.discardedMap;
> @@ -1804,7 +1873,7 @@ abstract public class BaseQATest extends
>                     long finishTime = startTime + 1000;
>                     long remain = 1000;
>                     do {
> -                        listener.wait(remain); // Wait for discovery for 1000 ms.
> +                        listener.discarded.await(remain, TimeUnit.MILLISECONDS); // Wait for discovery for 1000 ms.
>                         remain = finishTime - System.currentTimeMillis();
>                     } while (remain > 0); //To avoid spurious wakeup
>                 } catch (InterruptedException ex) {
> @@ -1813,9 +1882,12 @@ abstract public class BaseQATest extends
>                 //DiscoveryServiceUtil.delayMS(1000);
>                 showCompInfo = false;//display comparison info only when i = 0
>             }//end loop(iLoop)
> -        }//end sync(listener)
> +        } finally {
> +            listener.lock.unlock();
> +        }
>         logger.log(Level.FINE, " DISCARD wait period complete");
> -        synchronized(listener) {
> +        listener.lock.lock();
> +        try {
>             if(!discardComplete) {
>                 throw new TestException("discard failed -- "
>                                          +"waited "+nSecsToWait1
> @@ -1831,7 +1903,9 @@ abstract public class BaseQATest extends
>                               +" discard event(s) expected, "
>                               +listener.discardedMap.size()
>                               +" discard event(s) received");
> -        }//end sync(listener)
> +        } finally {
> +            listener.lock.unlock();
> +        }
>     }//end waitForDiscard
> 
>     /** Common code shared by each test that needs to wait for changed
> @@ -1868,7 +1942,8 @@ abstract public class BaseQATest extends
>         boolean changeComplete = false;
>         boolean showCompInfo = true;//turn this off after 1st pass thru loop
> 	Map changedClone = null;
> -        synchronized (listener){
> +        listener.lock.lock();
> +        try {
>         iLoop:
>             for(int i=0;i<nSecsToWait1;i++) {
>                 Map changedMap = listener.changedMap;
> @@ -1964,7 +2039,7 @@ abstract public class BaseQATest extends
>                     long finishTime = startTime + 1000;
>                     long remain = 1000;
>                     do {
> -                        listener.wait(remain); // Wait for discovery for 1000 ms.
> +                        listener.changed.await(remain, TimeUnit.MILLISECONDS); // Wait for discovery for 1000 ms.
>                         remain = finishTime - System.currentTimeMillis();
>                     } while (remain > 0); //To avoid spurious wakeup
>                 } catch (InterruptedException ex) {
> @@ -1974,9 +2049,12 @@ abstract public class BaseQATest extends
>                 //DiscoveryServiceUtil.delayMS(1000);
>                 showCompInfo = false;//display comparison info only when i = 0
>             }//end loop(iLoop)
> -        }//end sync(listener)
> +        } finally {
> +            listener.lock.unlock();
> +        }
>         logger.log(Level.FINE, " CHANGE wait period complete");
> -        synchronized(listener) {
> +        listener.lock.lock();
> +        try {
>             if(!changeComplete) {
>                 throw new TestException("change failed -- "
>                                          +"waited "+nSecsToWait1
> @@ -1992,7 +2070,9 @@ abstract public class BaseQATest extends
>                               +" change event(s) expected, "
>                               +listener.changedMap.size()
>                               +" change event(s) received");
> -        }//end sync(listener)
> +        } finally {
> +            listener.lock.unlock();
> +        }
>     }//end waitForChange
> 
>     /** Given two locator-to-groups mappings, this method compares both
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LookupServices.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LookupServices.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LookupServices.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/share/LookupServices.java Thu Jan  2 02:45:07 2014
> @@ -575,8 +575,9 @@ public class LookupServices {
>                 if(debugsync) logger.log(Level.FINE,
>                                   "     BaseQATest.startLookup - "
>                                   +"sync on lookupList --> released");
> +                genMap.put( lookupProxy, memberGroups );
>             }//end sync(lookupList)
> -            genMap.put( lookupProxy, memberGroups );
> +            
>             /* Force non-unique groups for manual tests */
>             if(    (testType == BaseQATest.MANUAL_TEST_REMOTE_COMPONENT)
>                 || (testType == BaseQATest.MANUAL_TEST_LOCAL_COMPONENT) ) 
> @@ -605,7 +606,7 @@ public class LookupServices {
>             }
>         }
>         regsToLocGroupsMap.put(lookupProxy,locGroupsPair);
> -
> +        
>         LocatorsUtil.displayLocator(lookupLocator,
>                                     "  locator",Level.FINE);
>         String displayGroups = GroupsUtil.toCommaSeparatedStr(memberGroups);
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/DiscardUnreachable.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/DiscardUnreachable.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/DiscardUnreachable.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/DiscardUnreachable.java Thu Jan  2 02:45:07 2014
> @@ -82,7 +82,9 @@ public class DiscardUnreachable extends 
>          * are examined; so those maps shouldn't be allowed to change
>          * they have been examined.
>          */
> -        synchronized(mainListener) {
> +        LookupListener mainListener = this.mainListener;
> +        mainListener.lock.lock();
> +        try {
>             logger.log(Level.FINE, "terminating each lookup service ...");
>             /* Stop announcements & destroy all lookups started in construct */
>             terminateAllLookups();
> @@ -95,7 +97,9 @@ public class DiscardUnreachable extends 
>                                                              mainListener);
>             /* Set the expected discard event info */
>             mainListener.setLookupsToDiscover(locGroupsNotDiscarded);
> -        }//end sync(mainListener)
> +        } finally {
> +            mainListener.lock.unlock();
> +        }
>         waitForDiscard(mainListener);
>     }
> }
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/GroupsMulticastMonitorReplace.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/GroupsMulticastMonitorReplace.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/GroupsMulticastMonitorReplace.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/GroupsMulticastMonitorReplace.java Thu Jan  2 02:45:07 2014
> @@ -88,7 +88,9 @@ public class GroupsMulticastMonitorRepla
>          * examines the contents of those maps. So we don't want those
>          * maps to change until setLookupsToDiscover returns.
>          */
> -        synchronized(mainListener) {
> +        LookupListener mainListener = this.mainListener;
> +        mainListener.lock.lock();
> +        try {
>             List locGroupsPairList = null;
>             /* Replace current groups with new groups to cause discards */
>             if(replacementGroups == null) {//use unique generated groups
> @@ -101,7 +103,9 @@ public class GroupsMulticastMonitorRepla
>             mainListener.setLookupsToDiscover(locGroupsPairList,
>                                                locatorsToDiscover,
>                                                groupsToDiscover);
> -        }//end sync(mainListener)
> +        } finally {
> +            mainListener.lock.unlock();
> +        }
>         waitForDiscard(mainListener);
>     }//end run
> 
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorChange.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorChange.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorChange.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorChange.java Thu Jan  2 02:45:07 2014
> @@ -84,14 +84,18 @@ public class MulticastMonitorChange exte
>          * examines the contents of those maps. So we don't want those
>          * maps to change until setLookupsToDiscover returns.
>          */
> -        synchronized(mainListener) {
> +        LookupListener mainListener = this.mainListener;
> +        mainListener.lock.lock();
> +        try {
>             /* Replace alternate groups to cause changed events */
>             List locGroupsPairList = replaceMemberGroups(true);
>             /* Set the expected changed event info */
>             mainListener.setLookupsToDiscover(locGroupsPairList,
>                                               locatorsToDiscover,
>                                               groupsToDiscover);
> -        }//end sync(mainListener)
> +        } finally {
> +            mainListener.lock.unlock();
> +        }
>         waitForChange((GroupChangeListener)mainListener);
>     }//end run
> 
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorReplace.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorReplace.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorReplace.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorReplace.java Thu Jan  2 02:45:07 2014
> @@ -79,14 +79,18 @@ public class MulticastMonitorReplace ext
>          * examines the contents of those maps. So we don't want those
>          * maps to change until setLookupsToDiscover returns.
>          */
> -        synchronized(mainListener) {
> +        LookupListener mainListener = this.mainListener;
> +        mainListener.lock.lock();
> +        try {
>             /* Replace all groups to cause discarded/changed events */
>             List locGroupsPairList = replaceMemberGroups(false);
>             /* Set the expected changed event info */
>             mainListener.setLookupsToDiscover(locGroupsPairList,
>                                               locatorsToDiscover,
>                                               groupsToDiscover);
> -        }//end sync(mainListener)
> +        } finally {
> +            mainListener.lock.unlock();
> +        }
>         waitForDiscard(mainListener);
>         logger.log(Level.FINE, 
> 		   "discarded events arrived as expected, "
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorReplaceNone.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorReplaceNone.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorReplaceNone.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorReplaceNone.java Thu Jan  2 02:45:07 2014
> @@ -69,7 +69,9 @@ public class MulticastMonitorReplaceNone
>          * examines the contents of those maps. So we don't want those
>          * maps to change until setLookupsToDiscover returns.
>          */
> -        synchronized(mainListener) {
> +        LookupListener mainListener = this.mainListener;
> +        mainListener.lock.lock();
> +        try {
>             /* Replace all groups with NO_GROUPS to generate events */
>             List locGroupsPairList = replaceMemberGroups
>                                       (DiscoveryGroupManagement.NO_GROUPS);
> @@ -77,7 +79,9 @@ public class MulticastMonitorReplaceNone
>             mainListener.setLookupsToDiscover(locGroupsPairList,
>                                               locatorsToDiscover,
>                                               groupsToDiscover);
> -        }//end sync(mainListener)
> +        } finally {
> +            mainListener.lock.unlock();
> +        }
>         waitForDiscard(mainListener);
>         logger.log(Level.FINE, 
> 		   "discarded events arrived as expected, "
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorStop.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorStop.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorStop.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorStop.java Thu Jan  2 02:45:07 2014
> @@ -103,14 +103,18 @@ public class MulticastMonitorStop extend
>          * examines the contents of those maps. So we don't want those
>          * maps to change until setLookupsToDiscover returns.
>          */
> -        synchronized(mainListener) {
> +        LookupListener mainListener = this.mainListener;
> +        mainListener.lock.lock();
> +        try {
>             stopAnnouncements();
>             /* Replace current groups with new groups to cause discards */
>             List locGroupsPairList = replaceMemberGroups(false);
>             mainListener.setLookupsToDiscover(locGroupsPairList,
>                                               locatorsToDiscover,
>                                               groupsToDiscover);
> -        }//end sync(mainListener)
> +        } finally {
> +            mainListener.lock.unlock();
> +        }
>         waitForDiscard(mainListener);
>         logger.log(Level.FINE, 
> 		   "discarded events arrived as expected, "
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorTerminate.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorTerminate.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorTerminate.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/MulticastMonitorTerminate.java Thu Jan  2 02:45:07 2014
> @@ -72,7 +72,9 @@ public class MulticastMonitorTerminate e
>          * are examined; so those maps shouldn't be allowed to change
>          * they have been examined.
>          */
> -        synchronized(mainListener) {
> +        LookupListener mainListener = this.mainListener;
> +        mainListener.lock.lock();
> +        try {
>             terminateAllLookups();//cause discard events to be sent
>             /* Since passive discards will NOT occur for those lookups
>              * that were discovered by only locator discovery, the 
> @@ -84,7 +86,9 @@ public class MulticastMonitorTerminate e
>                                     filterListByGroups(getInitLookupsToStart(),
>                                                        groupsToDiscover);
>             mainListener.setDiscardEventInfo(discoveredByGroupsList);
> -        }//end sync(mainListener)
> +        } finally {
> +            mainListener.lock.unlock();
> +        }
>         waitForDiscard(mainListener);
>     }//end run
> 
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/RemoveGroupsSome.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/RemoveGroupsSome.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/RemoveGroupsSome.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/RemoveGroupsSome.java Thu Jan  2 02:45:07 2014
> @@ -78,17 +78,10 @@ public class RemoveGroupsSome extends Di
>     public void run() throws Exception {
>         super.run();
>         setGroupsToRemove(getInitLookupsToStart(),alternateRemoval);
> -        /* Must sync on listener since Discovered/Discarded/Changed Map
> -         * will change as events arrive, and setLookupsToDiscover
> -         * examines the contents of those maps. So we don't want those
> -         * maps to change until setLookupsToDiscover returns.
> -         */
> -        synchronized(mainListener) {
> -            /* Set the expected discarded event info */
> -            mainListener.setLookupsToDiscover(getInitLookupsToStart(),
> -                                              locatorsToDiscover,
> -                                              newGroupsToDiscover);
> -        }//end sync(mainListener)
> +        /* Set the expected discarded event info */
> +        mainListener.setLookupsToDiscover(getInitLookupsToStart(),
> +                                          locatorsToDiscover,
> +                                          newGroupsToDiscover);
>         logger.log(Level.FINE, "remove groups to discover -- ");
>         if((groupsToRemove != null) && (groupsToRemove.length<=0)) {
>             logger.log(Level.FINE, "   NO_GROUPS");
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/SetGroupsReplaceSome.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/SetGroupsReplaceSome.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/SetGroupsReplaceSome.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/discoverymanager/SetGroupsReplaceSome.java Thu Jan  2 02:45:07 2014
> @@ -77,17 +77,10 @@ public class SetGroupsReplaceSome extend
>     public void run() throws Exception {
>         super.run();
>         setNewGroups(getInitLookupsToStart(),alternateReplacement);
> -        /* Must sync on listener since Discovered/Discarded/Changed Map
> -         * will change as events arrive, and setLookupsToDiscover
> -         * examines the contents of those maps. So we don't want those
> -         * maps to change until setLookupsToDiscover returns.
> -         */
> -        synchronized(mainListener) {
> -            /* Set the expected discarded event info */
> -            mainListener.setLookupsToDiscover(getInitLookupsToStart(),
> -                                              locatorsToDiscover,
> -                                              newGroupsToDiscover);
> -        }//end sync(mainListener)
> +        /* Set the expected discarded event info */
> +        mainListener.setLookupsToDiscover(getInitLookupsToStart(),
> +                                          locatorsToDiscover,
> +                                          newGroupsToDiscover);
>         logger.log(Level.FINE, "set new groups to discover -- ");
>         if((newGroupsToDiscover != null)&&(newGroupsToDiscover.length<=0)){
>             logger.log(Level.FINE, "   NO_GROUPS");
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/joinmanager/Register.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/joinmanager/Register.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/joinmanager/Register.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/joinmanager/Register.java Thu Jan  2 02:45:07 2014
> @@ -23,6 +23,7 @@ import java.util.logging.Level;
> import com.sun.jini.qa.harness.QAConfig;
> import com.sun.jini.qa.harness.Test;
> import com.sun.jini.qa.harness.TestException;
> +import java.util.List;
> 
> import net.jini.lookup.JoinManager;
> 
> @@ -74,8 +75,9 @@ public class Register extends AbstractBa
>         /* Verify that the lookups were discovered */
>         logger.log(Level.FINE, "verifying the lookup "
>                                         +"service(s) are discovered ...");
> -        mainListener.setLookupsToDiscover(getLookupsStarted(),
> -                                          toGroupsArray(getLookupsStarted()));
> +        List<LocatorGroupsPair> lookupsStarted = getLookupsStarted();
> +        mainListener.setLookupsToDiscover(lookupsStarted,
> +                                          toGroupsArray(lookupsStarted));
>         waitForDiscovery(mainListener);
>         verifyJoin();
>         logger.log(Level.FINE, "join manager successfully registered "
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/joinmanager/RegisterAttributes.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/joinmanager/RegisterAttributes.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/joinmanager/RegisterAttributes.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/joinmanager/RegisterAttributes.java Thu Jan  2 02:45:07 2014
> @@ -37,7 +37,7 @@ public class RegisterAttributes extends 
>      * <p>
>      *   Verifies that the test service input to the join manager constructor
>      *   is registered with all lookup services the join manager is configured
> -     *   to discover (through its <code>DiscoveryManagemen</code>t instance);
> +     *   to discover (through its <code>DiscoveryManagement</code> instance);
>      *   additionally, verifies that the test service's corresponding set of 
>      *   attributes are associated with the test service in each lookup service
>      *   in which that test service is registered.
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/locatordiscovery/DiscardUnreachable.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/locatordiscovery/DiscardUnreachable.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/locatordiscovery/DiscardUnreachable.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/locatordiscovery/DiscardUnreachable.java Thu Jan  2 02:45:07 2014
> @@ -86,7 +86,9 @@ public class DiscardUnreachable extends 
>          * the contents of those maps. So we don't want those maps to
>          * change until setLookupsToDiscover returns.
>          */
> -        synchronized(mainListener) {
> +        LookupListener mainListener = this.mainListener;
> +        mainListener.lock.lock();
> +        try {
>             logger.log(Level.FINE, "terminating each lookup service ...");
>             /* Stop announcements & destroy all lookups started in construct */
>             terminateAllLookups();
> @@ -101,7 +103,9 @@ public class DiscardUnreachable extends 
>              * for anything that we failed to discard)
>              */
>             mainListener.setLookupsToDiscover(locGroupsNotDiscarded);
> -        }//end sync(mainListener)
> +        } finally {
> +            mainListener.lock.unlock();
> +        }
>         waitForDiscard(mainListener);
>     }//end run
> 
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/ConstructorDups.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/ConstructorDups.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/ConstructorDups.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/ConstructorDups.java Thu Jan  2 02:45:07 2014
> @@ -29,6 +29,7 @@ import net.jini.discovery.DiscoveryGroup
> import net.jini.discovery.LookupDiscovery;
> 
> import java.util.ArrayList;
> +import java.util.List;
> 
> /**
>  * This class verifies that the <code>LookupDiscovery</code> utility
> @@ -55,9 +56,8 @@ import java.util.ArrayList;
>  */
> public class ConstructorDups extends AbstractBaseTest {
> 
> -    protected ArrayList newLookups = new ArrayList(11);
> -    protected String[] dupGroups = DiscoveryGroupManagement.NO_GROUPS;
> -    protected LookupDiscovery newLD = null;
> +    protected final ArrayList newLookups = new ArrayList(11);
> +    protected volatile String[] dupGroups = DiscoveryGroupManagement.NO_GROUPS;
> 
>     /** Performs actions necessary to prepare for execution of the 
>      *  current test (refer to the description of this method in the
> @@ -66,16 +66,15 @@ public class ConstructorDups extends Abs
>     public Test construct(QAConfig sysConfig) throws Exception {
> 	super.construct(sysConfig);
> 	/* Create a set of groups to discover that contain duplicates */
> -	int len1 = getAllLookupsToStart().size();
> +        List<LocatorGroupsPair> lookupsToStart = getAllLookupsToStart();
> +	int len1 = lookupsToStart.size();
> 	int len2 = 2*len1;
> 	for(int i=0;i<len1;i++) {
> -	    LocatorGroupsPair pair
> -		= (LocatorGroupsPair)getAllLookupsToStart().get(i);
> +	    LocatorGroupsPair pair = lookupsToStart.get(i);
> 	    newLookups.add(i,pair);
> 	}//end loop
> 	for(int i=len1;i<len2;i++) {
> -	    LocatorGroupsPair pair
> -		= (LocatorGroupsPair)getAllLookupsToStart().get(i-len1);
> +	    LocatorGroupsPair pair = lookupsToStart.get(i-len1);
> 	    newLookups.add(i,pair);
> 	}//end loop
> 	dupGroups = toGroupsArray(newLookups);
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/DiscardUnreachable.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/DiscardUnreachable.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/DiscardUnreachable.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/DiscardUnreachable.java Thu Jan  2 02:45:07 2014
> @@ -90,7 +90,9 @@ public class DiscardUnreachable extends 
>          * the contents of those maps. So we don't want those maps to
>          * change until setLookupsToDiscover returns.
>          */
> -        synchronized(mainListener) {
> +        LookupListener mainListener = this.mainListener;
> +        mainListener.lock.lock();
> +        try {
>             logger.log(Level.FINE,
>                               "terminating each lookup service ...");
>             /* Stop announcements & destroy all lookups started in construct */
> @@ -107,7 +109,9 @@ public class DiscardUnreachable extends 
>              * for anything that we failed to discard)
>              */
>             mainListener.setLookupsToDiscover(locGroupsNotDiscarded);
> -        }//end sync(mainListener)
> +        } finally {
> +            mainListener.lock.unlock();
> +        }
>         waitForDiscard(mainListener);
>     }//end run
> 
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorChange.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorChange.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorChange.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorChange.java Thu Jan  2 02:45:07 2014
> @@ -102,7 +102,9 @@ public class MulticastMonitorChange exte
>          * examines the contents of those maps. So we don't want those
>          * maps to change until setLookupsToDiscover returns.
>          */
> -        synchronized(listenerToUse) {
> +        LookupListener listenerToUse = this.listenerToUse;
> +        listenerToUse.lock.lock();
> +        try {
>             List locGroupsPairList = null;
>             /* Replace groups with new groups to cause changed events */
>             locGroupsPairList = replaceMemberGroups(alternateReplacements);
> @@ -110,7 +112,9 @@ public class MulticastMonitorChange exte
>             listenerToUse.setLookupsToDiscover
>                                      (locGroupsPairList,
>                                       groupsToDiscover);
> -        }//end sync(mainListener)
> +        } finally {
> +            listenerToUse.lock.unlock();
> +        }
>         waitForChange((GroupChangeListener)listenerToUse);
>     }//end run
> 
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorReplace.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorReplace.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorReplace.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorReplace.java Thu Jan  2 02:45:07 2014
> @@ -98,7 +98,9 @@ public class MulticastMonitorReplace ext
>          * examines the contents of those maps. So we don't want those
>          * maps to change until setLookupsToDiscover returns.
>          */
> -        synchronized(listenerToUse) {
> +        LookupListener listenerToUse = this.listenerToUse;
> +        listenerToUse.lock.lock();
> +        try {
>             List locGroupsPairList = null;
>             /* Replace current groups with new groups to cause discards */
>             if(replacementGroups == null) {//use unique generated groups
> @@ -111,7 +113,9 @@ public class MulticastMonitorReplace ext
>             listenerToUse.setLookupsToDiscover
>                                      (locGroupsPairList,
>                                       toGroupsArray(getInitLookupsToStart()));
> -        }//end sync(listenerToUse)
> +        } finally {
> +            listenerToUse.lock.unlock();
> +        }
>         waitForDiscard(listenerToUse);
>     }//end run
> 
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorStop.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorStop.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorStop.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorStop.java Thu Jan  2 02:45:07 2014
> @@ -94,10 +94,14 @@ public class MulticastMonitorStop extend
>          * changes the contents of those maps. So we don't want those
>          * maps to change due to events until clearAllEventInfo returns.
>          */
> -        synchronized(mainListener) {
> +        LookupListener mainListener = this.mainListener;
> +        mainListener.lock.lock();
> +        try {
>             stopAnnouncements();
>             mainListener.clearAllEventInfo();//expect no discard events
> -        }//end sync(mainListener)
> +        } finally {
> +            mainListener.lock.unlock();
> +        }
>         waitForDiscard(mainListener);
>     }//end run
> 
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorStopReplace.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorStopReplace.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorStopReplace.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorStopReplace.java Thu Jan  2 02:45:07 2014
> @@ -97,7 +97,9 @@ public class MulticastMonitorStopReplace
>          * examines the contents of those maps. So we don't want those
>          * maps to change until setLookupsToDiscover returns.
>          */
> -        synchronized(mainListener) {
> +        LookupListener mainListener = this.mainListener;
> +        mainListener.lock.lock();
> +        try {
>             stopAnnouncements();
>             /* Replace current groups with new groups to cause discards */
>             List locGroupsPairList = replaceMemberGroups();
> @@ -105,7 +107,9 @@ public class MulticastMonitorStopReplace
>             mainListener.setLookupsToDiscover
>                                      (locGroupsPairList,
>                                       toGroupsArray(getInitLookupsToStart()));
> -        }//end sync(mainListener)
> +        } finally {
> +            mainListener.lock.unlock();
> +        }
>         waitForDiscard(mainListener);
>     }//end run
> 
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorTerminate.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorTerminate.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorTerminate.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/lookupdiscovery/MulticastMonitorTerminate.java Thu Jan  2 02:45:07 2014
> @@ -105,10 +105,14 @@ public class MulticastMonitorTerminate e
>          * examines the contents of those maps. So we don't want those
>          * maps to change until setLookupsToDiscover returns.
>          */
> -        synchronized(mainListener) {
> +        LookupListener mainListener = this.mainListener;
> +        mainListener.lock.lock();
> +        try {
>             terminateAllLookups();//cause discard events to be sent
>             mainListener.setLookupsToDiscover(new java.util.ArrayList(1));
> -        }//end sync(mainListener)
> +        } finally {
> +            mainListener.lock.unlock();
> +        }
>         waitForDiscard(mainListener);
>     }//end run
> 
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/renewalmanager/LocalLease.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/renewalmanager/LocalLease.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/renewalmanager/LocalLease.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/test/spec/renewalmanager/LocalLease.java Thu Jan  2 02:45:07 2014
> @@ -36,6 +36,8 @@ import net.jini.core.lease.LeaseDeniedEx
> import net.jini.core.lease.UnknownLeaseException;
> 
> import com.sun.jini.test.share.OurAbstractLeaseMap;
> +import java.util.logging.Level;
> +import java.util.logging.Logger;
> 
> /**
>  * A lease implementation that is completely local for use in some of the 
> @@ -141,9 +143,15 @@ class LocalLease implements Lease {
>     }
> 
>     // Inherit java doc from super type
> -    public void cancel() throws RemoteException, UnknownLeaseException {
> -	// Simulate blocking remote communications
> -	Thread.yield();
> +    public synchronized void cancel() throws RemoteException, UnknownLeaseException {
> +        try {
> +            // Simulate blocking remote communications
> +            Thread.sleep(10000L);
> +        } catch (InterruptedException ex) {
> +            RemoteException e = new RemoteException();
> +            e.initCause(ex);
> +            throw e;
> +        }
>     }
> 
>     protected synchronized void renewWork(long duration) 
> 
> Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/config/Config.java
> URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/config/Config.java?rev=1554723&r1=1554722&r2=1554723&view=diff
> ==============================================================================
> --- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/config/Config.java (original)
> +++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/config/Config.java Thu Jan  2 02:45:07 2014
> @@ -86,8 +86,8 @@ public class Config {
>      * @see #getNonNullEntry(Configuration, String, String, Class, Object,
>      *      Object) 
>      */
> -    public static Object getNonNullEntry(Configuration config,
> -	    String component, String name, Class type)
> +    public static <T> T getNonNullEntry(Configuration config,
> +	    String component, String name, Class<T> type)
> 	throws ConfigurationException
>     {
> 	return getNonNullEntry(config, component, name, type,
> @@ -128,8 +128,8 @@ public class Config {
>      * @see #getNonNullEntry(Configuration, String, String, Class, Object,
>      *      Object) 
>      */
> -    public static Object getNonNullEntry(Configuration config,
> -	    String component, String name, Class type, Object defaultValue)
> +    public static <T> T getNonNullEntry(Configuration config,
> +	    String component, String name, Class<T> type, Object defaultValue)
> 	throws ConfigurationException
>     {
> 	return getNonNullEntry(config, component, name, type, defaultValue,
> @@ -177,15 +177,15 @@ public class Config {
>      * @see #getNonNullEntry(Configuration, String, String, Class, Object,
>      *      Object) 
>      */
> -    public static Object getNonNullEntry(Configuration config,
> -	    String component, String name, Class type, Object defaultValue,
> +    public static <T> T getNonNullEntry(Configuration config,
> +	    String component, String name, Class<T> type, Object defaultValue,
> 	    Object data)
> 	throws ConfigurationException
>     {
> 	if (defaultValue == null) 
> 	    throw new NullPointerException("defaultValue cannot be null");
> 
> -	final Object result = config.getEntry(component, name, type,
> +	final T result = (T) config.getEntry(component, name, type,
> 					      defaultValue, data);
> 
> 	if (result == null) {
> 
> 


Mime
View raw message