river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter_firmst...@apache.org
Subject svn commit: r1477969 - in /river/jtsk/skunk/qa_refactor/trunk: ./ qa/src/com/sun/jini/qa/harness/ src/com/sun/jini/start/ src/net/jini/core/discovery/ src/net/jini/loader/pref/ src/net/jini/lookup/ src/org/apache/river/api/net/ src/org/apache/river/api...
Date Wed, 01 May 2013 12:17:34 GMT
Author: peter_firmstone
Date: Wed May  1 12:17:33 2013
New Revision: 1477969

URL: http://svn.apache.org/r1477969
Log:
Tidy up dead code, commence removal of UriString library dependencies, replacing with org.apache.river.api.net.Uri.

Renamed org.apache.river.api.net.URLClassLoader to RFC3986URLClassLoader

Update junit tests.

Added:
    river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/RFC3986URLClassLoader.java
      - copied, changed from r1476991, river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/URLClassLoader.java
Removed:
    river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/URLClassLoader.java
Modified:
    river/jtsk/skunk/qa_refactor/trunk/build.xml
    river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/AbstractServiceAdmin.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/start/SharedActivationPolicyPermission.java
    river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/discovery/LookupLocator.java
    river/jtsk/skunk/qa_refactor/trunk/src/net/jini/loader/pref/PreferredClassLoader.java
    river/jtsk/skunk/qa_refactor/trunk/src/net/jini/loader/pref/PreferredClassProvider.java
    river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java
    river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/Uri.java
    river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/DefaultPolicyParser.java
    river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/PolicyUtils.java
    river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/URIGrant.java
    river/jtsk/skunk/qa_refactor/trunk/test/src/com/sun/jini/jeri/internal/mux/MuxStartTimeoutTest.java
    river/jtsk/skunk/qa_refactor/trunk/test/src/com/sun/jini/outrigger/FastListTest.java
    river/jtsk/skunk/qa_refactor/trunk/test/src/com/sun/jini/outrigger/TxnTableTest.java

Modified: river/jtsk/skunk/qa_refactor/trunk/build.xml
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/build.xml?rev=1477969&r1=1477968&r2=1477969&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/build.xml (original)
+++ river/jtsk/skunk/qa_refactor/trunk/build.xml Wed May  1 12:17:33 2013
@@ -907,7 +907,7 @@
             <arg value="net.jini.security.policy.DynamicPolicyProvider"/>
             <arg value="net.jini.security.policy.PolicyFileProvider"/>
             <arg value="org.apache.river.api.security.ConcurrentPolicyFile"/>
-            <arg value="org.apache.river.api.net.URLClassLoader"/>
+            <arg value="org.apache.river.api.net.RFC3986URLClassLoader"/>
             <arg line="-in com.sun.jini"/>
             <arg line="-in net.jini"/>
             <arg line="-in org.apache.river"/>

Modified: river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/AbstractServiceAdmin.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/AbstractServiceAdmin.java?rev=1477969&r1=1477968&r2=1477969&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/AbstractServiceAdmin.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/qa/src/com/sun/jini/qa/harness/AbstractServiceAdmin.java Wed May  1 12:17:33 2013
@@ -41,7 +41,7 @@ import net.jini.core.lookup.ServiceRegis
 import net.jini.discovery.ConstrainableLookupLocator;
 import net.jini.lookup.DiscoveryAdmin;
 import net.jini.security.ProxyPreparer;
-import org.apache.river.impl.net.UriString;
+import org.apache.river.api.net.Uri;
 
 /**
  * An abstract class supporting admins which use strings to identify
@@ -123,83 +123,83 @@ import org.apache.river.impl.net.UriStri
 public abstract class AbstractServiceAdmin implements Admin {
 
     /** The logger */
-    protected static Logger logger =
+    protected final static Logger logger =
 	Logger.getLogger("com.sun.jini.qa.harness");
 
     /** The config object for this test */
-    protected QAConfig config;
+    protected final QAConfig config;
 
     /** The name of the service controlled by this admin */
-    protected String serviceName;
+    protected final String serviceName;
 
     /** The instance number of this service in this test */
-    protected int index;
+    protected final int index;
 
     /** The codebase for the service */
-    private String codebase;
+    private volatile String codebase;
 
     /** The implementation class name of this service */
-    private String impl;
+    private volatile String impl;
 
     /** The policy file applied to this service */
-    private String policyFile;
+    private volatile String policyFile;
 
     /** The classpath for this service */
-    private String classpath;
+    private volatile String classpath;
 
     /** The vm to be used to run this service (uaually null) */
-    private String jvm;
+    private volatile String jvm;
 
     /** The command line options for the service VM */
-    private String[] options;
+    private volatile String[] options;
 
     /** The system properties for the service VM */
-    private String[] properties;
+    private volatile String[] properties;
 
     /** The activation host (usually null) */
-    private String activationHost;
+    private volatile String activationHost;
 
     /** The activation port (only used for non-null act host) */
-    private int activationPort;
+    private volatile int activationPort;
 
     /** The name of the service configuration file */
-    private String serviceConfigFile;
+    private volatile String serviceConfigFile;
 
     /** The name of the service starter configuration file */
-    private String starterConfig;
+    private volatile String starterConfig;
 
     /** The service directory (e.g. the doc directory for the class server */
-    private String dir;
+    private volatile String dir;
 
     /** The port associated with the service (e.g. the class server port */
-    private int port;
+    private volatile int port;
 
     /** Flag indicating a port was defined */
-    private boolean gotPort = false;
+    private volatile boolean gotPort = false;
 
     /** Groups associated with the service */
-    private String[] groups;
+    private volatile String[] groups;
 
     /** Locators associated with the service, expected to be non-null */
-    private LookupLocator[] locators = new LookupLocator[0];
+    private volatile LookupLocator[] locators = new LookupLocator[0];
 
     /** Member groups associated with a lookup service */
-    private String[] memberGroups;
+    private volatile String[] memberGroups;
 
     /** The name of the proxy preparer */
-    private String preparerName;
+    private volatile String preparerName;
 
     /** The name of the persistence directory */
-    private String logDirName; //XXX merge with dir?
+    private volatile String logDirName; //XXX merge with dir?
 
     /** The service type (for selecting the admin class) */
-    private String type;
+    private volatile String type;
 
     /** The transformer for munging the service descriptor */
-    protected ServiceDescriptorTransformer transformer = null;
+    protected volatile ServiceDescriptorTransformer transformer = null;
 
     /** The component name in the configuration file */
-    private String component;
+    private volatile String component;
 
     /**
      * Construct an <code>AbstractServicerAdmin</code>.
@@ -354,8 +354,9 @@ public abstract class AbstractServiceAdm
 	urls = new URI[st.countTokens()];
 	for (int i = 0; st.hasMoreTokens(); i++) {
             String uri = st.nextToken();
-            uri = UriString.fixWindowsURI(uri);
-            urls[i] = UriString.normalise(new URI(UriString.escapeIllegalCharacters(uri)));
+            uri = Uri.fixWindowsURI(uri);
+            urls[i] = Uri.uriToURI(Uri.parseAndCreate(uri));
+//            urls[i] = UriString.normalise(new URI(UriString.escapeIllegalCharacters(uri)));
 	}
 	return urls;
     }

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/start/SharedActivationPolicyPermission.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/start/SharedActivationPolicyPermission.java?rev=1477969&r1=1477968&r2=1477969&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/start/SharedActivationPolicyPermission.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/start/SharedActivationPolicyPermission.java Wed May  1 12:17:33 2013
@@ -32,7 +32,7 @@ import java.util.Collections;
 import java.util.Enumeration;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import org.apache.river.impl.net.UriString;
+import org.apache.river.api.net.Uri;
 
 /**
  * {@link Permission} class used by the 
@@ -153,9 +153,10 @@ public final class SharedActivationPolic
             if (policy.startsWith("file:") || policy.startsWith("FILE:")){
                 String path = null;
                 try {
-                    uncanonicalPath = UriString.fixWindowsURI(uncanonicalPath);
-                    uncanonicalPath = UriString.escapeIllegalCharacters(uncanonicalPath);
-                    path = new File(new URI(uncanonicalPath)).getPath();
+                    uncanonicalPath = Uri.fixWindowsURI(uncanonicalPath);
+//                    uncanonicalPath = Uri.escapeIllegalCharacters(uncanonicalPath);
+                    path = Uri.uriToFile(Uri.escapeAndCreate(uncanonicalPath)).getPath();
+//                    path = new File(new URI(uncanonicalPath)).getPath();
                 } catch (URISyntaxException ex) {
                     path = uncanonicalPath.replace('/', File.separatorChar);
                 } catch (IllegalArgumentException ex){

Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/discovery/LookupLocator.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/discovery/LookupLocator.java?rev=1477969&r1=1477968&r2=1477969&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/discovery/LookupLocator.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/core/discovery/LookupLocator.java Wed May  1 12:17:33 2013
@@ -35,7 +35,7 @@ import java.security.PrivilegedAction;
 import net.jini.core.lookup.ServiceRegistrar;
 import net.jini.discovery.ConstrainableLookupLocator;
 import net.jini.discovery.LookupLocatorDiscovery;
-import org.apache.river.impl.net.UriString;
+import org.apache.river.api.net.Uri;
 
 /**
  * LookupLocator supports unicast discovery, using only version 1 of the
@@ -186,9 +186,10 @@ public class LookupLocator implements Se
 	}
 	URI uri = null;
 	try {
-            url = UriString.escapeIllegalCharacters(url);
-	    uri = new URI(url);
-            uri = UriString.normalise(uri);
+            uri = Uri.uriToURI(Uri.parseAndCreate(url));
+//            url = UriString.escapeIllegalCharacters(url);
+//	    uri = new URI(url);
+//            uri = UriString.normalise(uri);
 	} catch (URISyntaxException e) {
 	    MalformedURLException mue =
 		new MalformedURLException("URI parsing failure: " + url);

Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/loader/pref/PreferredClassLoader.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/loader/pref/PreferredClassLoader.java?rev=1477969&r1=1477968&r2=1477969&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/loader/pref/PreferredClassLoader.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/loader/pref/PreferredClassLoader.java Wed May  1 12:17:33 2013
@@ -50,7 +50,7 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import net.jini.loader.ClassAnnotation;
 import net.jini.loader.DownloadPermission;
-import org.apache.river.api.net.URLClassLoader;
+import org.apache.river.api.net.RFC3986URLClassLoader;
 
 /**
  * A class loader that supports preferred classes.
@@ -224,7 +224,7 @@ import org.apache.river.api.net.URLClass
  * @author Sun Microsystems, Inc.
  * @since 2.0
  **/
-public class PreferredClassLoader extends URLClassLoader
+public class PreferredClassLoader extends RFC3986URLClassLoader
     implements ClassAnnotation
 {
     /**
@@ -1029,6 +1029,44 @@ public class PreferredClassLoader extend
 	}
 	return null;
     }
+    
+    /**
+     * Gets an Enumeration of resources with the specified name.
+     *
+     * <p><code>PreferredClassLoader</code> implements this method as
+     * follows:
+     *
+     * <p>This method invokes {@link #isPreferredResource
+     * isPreferredResource} with <code>name</code> as the first
+     * argument and <code>false</code> as the second argument:
+     *
+     * <ul>
+     *
+     * <li>If <code>isPreferredResource</code> returns
+     * <code>true</code>, then this method invokes {@link
+     * #findResources findResources} with <code>name</code> and returns
+     * the results.
+     *
+     * <li>If <code>isPreferredResource</code> returns
+     * <code>false</code>, then this method invokes the superclass
+     * implementation of {@link ClassLoader#getResources getResources}
+     * with <code>name</code> and returns the result.
+     *
+     * </ul>
+     *
+     * @param name the name of the resource to get
+     *
+     * @return an <code>Enumeration</code> for the resource, the
+     * <code>Enumeration</code> is empty if the resource could not be found
+     * 
+     * @throws an IOException if isPreferredResource throws an IOException.
+     * 
+     * @since 2.3.0
+     **/
+    public Enumeration<URL> getResources(String name) throws IOException{
+        return (isPreferredResource(name, false) ?
+                findResources(name) : super.getResources(name));
+    }
 
     /*
      * Work around 4841786: wrap ClassLoader.definePackage so that if

Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/loader/pref/PreferredClassProvider.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/loader/pref/PreferredClassProvider.java?rev=1477969&r1=1477968&r2=1477969&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/loader/pref/PreferredClassProvider.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/loader/pref/PreferredClassProvider.java Wed May  1 12:17:33 2013
@@ -31,7 +31,6 @@ import java.lang.ref.WeakReference;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Proxy;
 import java.net.MalformedURLException;
-import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLConnection;
@@ -48,10 +47,8 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import java.util.StringTokenizer;
-import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.logging.Logger;
@@ -59,7 +56,6 @@ import java.util.logging.Level;
 import net.jini.loader.ClassAnnotation;
 import net.jini.loader.DownloadPermission;
 import org.apache.river.api.net.Uri;
-import org.apache.river.impl.net.UriString;
 
 /**
  * An <code>RMIClassLoader</code> provider that supports preferred

Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java?rev=1477969&r1=1477968&r2=1477969&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/lookup/ServiceDiscoveryManager.java Wed May  1 12:17:33 2013
@@ -66,6 +66,7 @@ import java.rmi.server.UnicastRemoteObje
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -692,7 +693,7 @@ public class ServiceDiscoveryManager {
     private final static class ServiceDiscoveryListenerImpl
                                           implements ServiceDiscoveryListener
     {
-	ArrayList items = new ArrayList(1);
+	final ArrayList items = new ArrayList(1);
 	public synchronized void serviceAdded(ServiceDiscoveryEvent event) {
 	    items.add(event.getPostEventServiceItem());
 	    this.notifyAll();
@@ -714,15 +715,15 @@ public class ServiceDiscoveryManager {
      */
     private final static class EventReg  {
         /* The Event source from the event registration */
-        Object source;
+        final Object source;
         /* The Event ID */
-        public long eventID;
+        public final long eventID;
 	/* The current event sequence number for the Service template */
 	public long seqNo;
 	/* The Event notification lease */
-	public Lease lease;
+	public final Lease lease;
 	/* The pending events */
-	public ArrayList pending;
+	public final ArrayList pending;
 	/* The number of pending LookupTasks */
 	public int lookupsPending;
         public EventReg(Object source, long eventID, long seqNo, Lease lease) {
@@ -742,7 +743,7 @@ public class ServiceDiscoveryManager {
      */
     private final static class ServiceItemReg  {
 	/* Maps ServiceRegistrars to their latest registered item */
-	private final Map items = new HashMap();
+	private final Map<ServiceRegistrar,ServiceItem> items = new HashMap<ServiceRegistrar,ServiceItem>();
 	/* The ServiceRegistrar currently being used to track changes */
 	private ServiceRegistrar proxy;
 	/* Flag that indicates that the ServiceItem has been discarded. */
@@ -1509,11 +1510,11 @@ public class ServiceDiscoveryManager {
 	/* Flag that indicates if the LookupCache has been terminated. */
 	private boolean bCacheTerminated = false;
 	/* Contains the ServiceDiscoveryListener's that receive local events */
-	private final ArrayList sItemListeners = new ArrayList(1);
+	private final ArrayList<ServiceDiscoveryListener> sItemListeners = new ArrayList<ServiceDiscoveryListener>(1);
 	/* Map from ServiceID to ServiceItemReg */
-	private final HashMap serviceIdMap = new HashMap();
+	private final HashMap<ServiceID,ServiceItemReg> serviceIdMap = new HashMap<ServiceID,ServiceItemReg>();
 	/* Map from ProxyReg to EventReg: (proxyReg, {source,id,seqNo,lease})*/
-	private final HashMap eventRegMap = new HashMap();
+	private final HashMap<ProxyReg,EventReg> eventRegMap = new HashMap<ProxyReg,EventReg>();
 	/* Template current cache instance should use for primary matching */
 	private ServiceTemplate tmpl;
 	/* Filter current cache instance should use for secondary matching */
@@ -1527,7 +1528,7 @@ public class ServiceDiscoveryManager {
         /** For tasks waiting on verification events after service discard */
         private TaskManager serviceDiscardTimerTaskMgr;
         /* Thread mutex used to interrupt all ServiceDiscardTimerTasks */
-        private Object serviceDiscardMutex = new Object();
+        private final Object serviceDiscardMutex = new Object();
         /** Whenever a ServiceIdTask is created in this cache, it is assigned
          *  a unique sequence number to allow such tasks associated with the
          *  same ServiceID to be executed in the order in which they were
@@ -1550,14 +1551,7 @@ public class ServiceDiscoveryManager {
 	    synchronized(sItemListeners) {
 		if(sListener != null ) sItemListeners.add(sListener);
 	    }//end sync(sItemListeners)
-            ArrayList set;
-            synchronized(proxyRegSet) {
-                set = (ArrayList)proxyRegSet.clone();
-            }//end sync(proxyRegSet)
-	    for(int i=0; i<set.size(); i++) {
-		ProxyReg reg = (ProxyReg)set.get(i);
-                addProxyReg(reg);
-	    }//end loop
+            
 	}//end constructor
 
 	// This method's javadoc is inherited from an interface of this class
@@ -2245,6 +2239,14 @@ public class ServiceDiscoveryManager {
                 serviceDiscardTimerTaskMgr = new TaskManager
                                                          (10,(15*1000),1.0f);
             }
+            ArrayList set;
+            synchronized(proxyRegSet) {
+                set = new ArrayList(proxyRegSet);
+            }//end sync(proxyRegSet)
+	    for(int i=0; i<set.size(); i++) {
+		ProxyReg reg = (ProxyReg)set.get(i);
+                addProxyReg(reg);
+	    }//end loop
         }//end LookupCacheImpl.initCache
 
 	/** Applies the first-stage <code>filter</code> associated with
@@ -2452,45 +2454,45 @@ public class ServiceDiscoveryManager {
     /* Logger used by this utility. */
     private static final Logger logger = Logger.getLogger(COMPONENT_NAME);
     /* The discovery manager to use (passed in, or create one). */
-    private DiscoveryManagement discMgr;
+    private final DiscoveryManagement discMgr;
     /* Indicates whether the discovery manager was created internally or not */
-    private boolean discMgrInternal = false;
+    private final boolean discMgrInternal;
     /* The listener added to discMgr that receives DiscoveryEvents */
-    private DiscMgrListener discMgrListener = new DiscMgrListener();
+    private final DiscMgrListener discMgrListener;
     /* The LeaseRenewalManager to use (passed in, or create one). */
-    private LeaseRenewalManager leaseRenewalMgr;
+    private final LeaseRenewalManager leaseRenewalMgr;
     /* Contains all of the discovered lookup services (ServiceRegistrar). */
-    private final ArrayList proxyRegSet = new ArrayList(1);
+    private final List<ProxyReg> proxyRegSet = new ArrayList<ProxyReg>(1);
     /* Contains all of the DiscoveryListener's employed in lookup discovery. */
-    private final ArrayList<DiscoveryListener> listeners = new ArrayList<DiscoveryListener>(1);
+    private final List<DiscoveryListener> listeners = new ArrayList<DiscoveryListener>(1);
     /* Random number generator for use in lookup. */
     private final Random random = new Random();
     /* Contains all of the instances of LookupCache that are requested. */
-    private final ArrayList caches = new ArrayList(1);
+    private final ArrayList<LookupCache> caches = new ArrayList<LookupCache>(1);
 
     /* Flag to indicate if the ServiceDiscoveryManager has been terminated. */
     private boolean bTerminated = false;
     /* Object used to obtain the configuration items for this utility. */
-    private Configuration thisConfig;
+    private final Configuration thisConfig;
     /* Preparer for the proxies to the lookup services that are discovered
      * and used by this utility.
      */
-    private ProxyPreparer registrarPreparer;
+    private final ProxyPreparer registrarPreparer;
     /* Preparer for the proxies to the leases returned to this utility when
      * it registers with the event mechanism of any of the discovered lookup
      * services.
      */
-    private ProxyPreparer eventLeasePreparer;
+    private final ProxyPreparer eventLeasePreparer;
     /* Wait value used when handling the "service discard problem". */
-    private long discardWait = 2*(5*60*1000);
+    private final long discardWait;
 
     /* Listener class for lookup service discovery notification. */
-    private class DiscMgrListener implements DiscoveryListener {
+    private class DiscMgrListener implements DiscoveryListener {    
 	/* New or previously discarded proxy has been discovered. */
 	public void discovered(DiscoveryEvent e) {
-	    ServiceRegistrar[] proxys = (ServiceRegistrar[])e.getRegistrars();
-	    ArrayList newProxys = new ArrayList(1);
-	    ArrayList notifies  = null;
+	    ServiceRegistrar[] proxys = e.getRegistrars();
+	    ArrayList<ProxyReg> newProxys = new ArrayList<ProxyReg>(1);
+	    ArrayList<DiscoveryListener> notifies  = null;
 	    for(int i=0; i<proxys.length; i++) {
                 /* Prepare each lookup service proxy before using it. */
                 try {
@@ -2516,11 +2518,11 @@ public class ServiceDiscoveryManager {
 	    }//end loop
 	    synchronized(listeners) {
 		if(!listeners.isEmpty())
-		    notifies = (ArrayList)listeners.clone();
+		    notifies = new ArrayList<DiscoveryListener>(listeners);
 	    }//end sync(listeners)
-	    Iterator iter = newProxys.iterator();
+	    Iterator<ProxyReg> iter = newProxys.iterator();
 	    while(iter.hasNext()) {
-		ProxyReg reg = (ProxyReg)iter.next();
+		ProxyReg reg = iter.next();
 		cacheAddProxy(reg);
 		if(notifies != null)  listenerDiscovered(reg.getProxy(), notifies);
 	    }//end loop
@@ -2528,9 +2530,9 @@ public class ServiceDiscoveryManager {
 
 	/* Previously discovered proxy has been discarded. */
 	public void discarded(DiscoveryEvent e) {
-	    ServiceRegistrar[] proxys = (ServiceRegistrar[])e.getRegistrars();
-	    ArrayList notifies;
-	    ArrayList<ProxyReg> drops = new ArrayList<ProxyReg>(1);
+	    ServiceRegistrar[] proxys = e.getRegistrars();
+	    List<DiscoveryListener> notifies;
+	    List<ProxyReg> drops = new ArrayList<ProxyReg>(1);
 	    synchronized(proxyRegSet) {
 		for(int i=0; i<proxys.length; i++) {
 		    ProxyReg reg = findReg(proxys[i]);
@@ -2549,13 +2551,19 @@ public class ServiceDiscoveryManager {
 		dropProxy(iter.next());
             }//end loop
             if (!drops.isEmpty()){
+                notifies = new LinkedList<DiscoveryListener>();
                 synchronized(listeners) {
                     if(listeners.isEmpty()) return;
-                    notifies = (ArrayList)listeners.clone();
+                    notifies.addAll(listeners);
                 }//end sync(listeners)
                 listenerDropped(drops, notifies);
             }
 	}//end DiscMgrListener.discarded
+        
+        /** Discards a ServiceRegistrar through the discovery manager.*/
+        private void discard(ServiceRegistrar proxy) {
+            discMgr.discard(proxy);
+        }//end discard
 
     }//end class ServiceDiscoveryManager.DiscMgrListener
 
@@ -2749,9 +2757,9 @@ public class ServiceDiscoveryManager {
                                    LeaseRenewalManager leaseMgr)
                                                             throws IOException
     {
-        try {
-            init(discoveryMgr, leaseMgr, EmptyConfiguration.INSTANCE);
-        } catch(ConfigurationException e) { /* swallow this exception */ }
+        
+            this(initial(discoveryMgr, leaseMgr, EmptyConfiguration.INSTANCE));
+        
     }//end constructor
 
     /**
@@ -2822,48 +2830,61 @@ public class ServiceDiscoveryManager {
                                                 throws IOException,
                                                        ConfigurationException
     {
-        init(discoveryMgr, leaseMgr, config);
+        this(init(discoveryMgr, leaseMgr, config));
     }//end constructor
+    
+    private ServiceDiscoveryManager(Initializer init){
+        thisConfig = init.thisConfig;
+        registrarPreparer = init.registrarPreparer;
+        eventLeasePreparer = init.eventLeasePreparer;
+        leaseRenewalMgr = init.leaseRenewalMgr;
+        discardWait = init.discardWait.longValue();
+        discMgr = init.discMgr;
+        discMgrInternal = init.discMgrInternal;
+        discMgrListener = new DiscMgrListener();
+        discMgr.addDiscoveryListener(discMgrListener);
+    }
 
     /** Sends discarded event to each listener waiting for discarded lookups.*/
-    private void listenerDropped(ArrayList drops, ArrayList notifies) {
+    private void listenerDropped(List<ProxyReg> drops, List<DiscoveryListener> notifies) {
 	ServiceRegistrar[] proxys = new ServiceRegistrar[drops.size()];
 	drops.toArray(proxys);
 	listenerDropped(proxys, notifies);
     }//end listenerDropped
 
     /** Sends discarded event to each listener waiting for discarded lookups.*/
-    private void listenerDropped(ServiceRegistrar[] proxys,ArrayList notifies){
-	Iterator iter = notifies.iterator();
+    private void listenerDropped(ServiceRegistrar[] proxys, List<DiscoveryListener> notifies){
+	Iterator<DiscoveryListener> iter = notifies.iterator();
 	while (iter.hasNext()) {
 	    DiscoveryEvent evt = new DiscoveryEvent
-                                        ( this,
-                                          (ServiceRegistrar[])proxys.clone() );
-	    ((DiscoveryListener)iter.next()).discarded(evt);
+                                        ( this, proxys.clone());
+	    iter.next().discarded(evt);
 	}//end loop
     }//end listenerDropped
 
     /** Sends discovered event to each listener listening for new lookups. */
-    private void listenerDiscovered(ServiceRegistrar proxy,ArrayList notifies){
-	Iterator iter = notifies.iterator();
+    private void listenerDiscovered(ServiceRegistrar proxy, List<DiscoveryListener> notifies){
+	Iterator<DiscoveryListener> iter = notifies.iterator();
 	while (iter.hasNext()) {
 	    DiscoveryEvent evt = new DiscoveryEvent
                                         ( this,
                                           new ServiceRegistrar[]{proxy} );
-	    ((DiscoveryListener)iter.next()).discovered(evt);
+	    iter.next().discovered(evt);
 	}//end loop
     }//end listenerDiscovered
 
     /** Returns array of ServiceRegistrar created from the proxyRegSet */
     private ServiceRegistrar[] buildServiceRegistrar() {
-	int k = 0;
-	ServiceRegistrar[] proxys = new ServiceRegistrar[proxyRegSet.size()];
-	Iterator iter = proxyRegSet.iterator();
-	while(iter.hasNext()) {
-	    ProxyReg reg = (ProxyReg)iter.next();
-	    proxys[k++] = reg.getProxy();
-	}//end loop
-	return proxys;
+        synchronized (proxyRegSet){
+            int k = 0;
+            ServiceRegistrar[] proxys = new ServiceRegistrar[proxyRegSet.size()];
+            Iterator<ProxyReg> iter = proxyRegSet.iterator();
+            while(iter.hasNext()) {
+                ProxyReg reg = iter.next();
+                proxys[k++] = reg.getProxy();
+            }//end loop
+            return proxys;
+        }
     }//end buildServiceRegistrar
 
     /**
@@ -2944,10 +2965,7 @@ public class ServiceDiscoveryManager {
      */
     public ServiceItem lookup(ServiceTemplate tmpl, ServiceItemFilter filter) {
 	checkTerminated();
-	ServiceRegistrar[] proxys;
-	synchronized(proxyRegSet) {
-	    proxys =  buildServiceRegistrar();
-	}
+	ServiceRegistrar[] proxys = buildServiceRegistrar();
 	int len = proxys.length;
 	if(len == 0 ) return null;
 	int rand = random.nextInt(Integer.MAX_VALUE) % len;
@@ -3338,12 +3356,10 @@ public class ServiceDiscoveryManager {
 	if (maxMatches < 1)
 	    throw new IllegalArgumentException("maxMatches must be > 0");
         /* retrieve the lookup service(s) to query for matching service(s) */
-	ServiceRegistrar[] proxys;
-	synchronized(proxyRegSet) {
-	    proxys =  buildServiceRegistrar();
-	}
+	ServiceRegistrar[] proxys = buildServiceRegistrar();
+	
 	int len = proxys.length;
-	ArrayList sItemSet = new ArrayList(len);
+	List<ServiceItem> sItemSet = new ArrayList<ServiceItem>(len);
 	if(len > 0) {
             /* loop thru the set of lookups, randomly selecting each lookup */
 	    int rand = (random.nextInt(Integer.MAX_VALUE)) % len;
@@ -3382,8 +3398,8 @@ public class ServiceDiscoveryManager {
 			if(!isArrayContainsServiceItem(sItemSet, sItem))
 			    sItemSet.add(sItem);
 			if(sItemSet.size() >= maxMatches) {
-                            return (ServiceItem [])(sItemSet.toArray
-                                           (new ServiceItem[sItemSet.size()]));
+                            return sItemSet.toArray
+                          (new ServiceItem[sItemSet.size()]);
 			}
 		    }//end loop(j)
 		} catch(Exception e) {
@@ -3614,8 +3630,8 @@ public class ServiceDiscoveryManager {
                                                        throws RemoteException
     {
 	if(tmpl == null) tmpl = new ServiceTemplate(null, null, null);
-	LookupCacheImpl cache = new LookupCacheImpl(tmpl, filter,
-                                                    listener, leaseDuration);
+	LookupCacheImpl cache = new LookupCacheImpl(tmpl, filter, listener, leaseDuration);
+        cache.initCache();
 	synchronized(caches) {
 	    caches.add(cache);
 	}
@@ -3784,10 +3800,10 @@ public class ServiceDiscoveryManager {
     }//end copyServiceTemplate
 
     /** Determines if the given ServiceItem is an element of the given array.*/
-    static private boolean isArrayContainsServiceItem(ArrayList a,
+    static private boolean isArrayContainsServiceItem(List<ServiceItem> a,
                                                       ServiceItem s)
     {
-	Iterator iter = a.iterator();
+	Iterator<ServiceItem> iter = a.iterator();
 	while(iter.hasNext()) {
 	    Object o = iter.next();
 	    if ( !(o instanceof ServiceItem )) continue;
@@ -3800,62 +3816,83 @@ public class ServiceDiscoveryManager {
 	return false;
     }//end isArrayContainsServiceItems
 
+    private static class Initializer {
+        Configuration thisConfig;
+        ProxyPreparer registrarPreparer;
+        ProxyPreparer eventLeasePreparer;
+        LeaseRenewalManager leaseRenewalMgr;
+        Long discardWait = Long.valueOf( 2*(5*60*1000));
+        DiscoveryManagement discMgr;
+        boolean discMgrInternal;
+        DiscMgrListener discMgrListener;
+    }
+    
+    private static Initializer initial(DiscoveryManagement discoveryMgr, LeaseRenewalManager leaseMgr, Configuration config) throws IOException {
+        try {
+            return init(discoveryMgr, leaseMgr, EmptyConfiguration.INSTANCE);
+        } catch(ConfigurationException e) { 
+            /* This should never happen */
+            throw new IOException(e);
+        }
+    }
+    
     /* Convenience method that encapsulates the retrieval of the configurable
      * items from the given <code>Configuration</code> object.
      */
-    private void init(DiscoveryManagement discoveryMgr,
+    private static Initializer init(DiscoveryManagement discoveryMgr,
                       LeaseRenewalManager leaseMgr,
                       Configuration config)
                                     throws IOException, ConfigurationException
     {
+        Initializer init = new Initializer();
         /* Retrieve configuration items if applicable */
         if(config == null)  throw new NullPointerException("config is null");
-        thisConfig = config;
+        init.thisConfig = config;
         /* Proxy preparers */
-        registrarPreparer = (ProxyPreparer)thisConfig.getEntry
+        init.registrarPreparer = (ProxyPreparer)init.thisConfig.getEntry
                                                     (COMPONENT_NAME,
                                                      "registrarPreparer",
                                                      ProxyPreparer.class,
                                                      new BasicProxyPreparer());
-        eventLeasePreparer = (ProxyPreparer)thisConfig.getEntry
+        init.eventLeasePreparer = (ProxyPreparer)init.thisConfig.getEntry
                                                    (COMPONENT_NAME,
                                                     "eventLeasePreparer",
                                                     ProxyPreparer.class,
                                                     new BasicProxyPreparer());
         /* Lease renewal manager */
-        leaseRenewalMgr = leaseMgr;
-	if(leaseRenewalMgr == null) {
+        init.leaseRenewalMgr = leaseMgr;
+	if(init.leaseRenewalMgr == null) {
             try {
-                leaseRenewalMgr
-                   = (LeaseRenewalManager)thisConfig.getEntry
+                init.leaseRenewalMgr
+                   = (LeaseRenewalManager)init.thisConfig.getEntry
                                                  (COMPONENT_NAME,
                                                   "leaseManager",
                                                   LeaseRenewalManager.class);
             } catch(NoSuchEntryException e) { /* use default */
-                leaseRenewalMgr = new LeaseRenewalManager(thisConfig);
+                init.leaseRenewalMgr = new LeaseRenewalManager(init.thisConfig);
             }
         }//endif
         /* Wait value for the "service discard problem". */
-        discardWait = ((Long)thisConfig.getEntry
+        init.discardWait = ((Long) init.thisConfig.getEntry
                                           (COMPONENT_NAME,
                                            "discardWait",
                                            long.class,
-                                           Long.valueOf(discardWait))).longValue();
+                                           init.discardWait)).longValue();
         /* Discovery manager */
-        discMgr = discoveryMgr;
-	if(discMgr == null) {
-	    discMgrInternal = true;
+        init.discMgr = discoveryMgr;
+	if(init.discMgr == null) {
+	    init.discMgrInternal = true;
             try {
-                discMgr = (DiscoveryManagement)thisConfig.getEntry
+                init.discMgr = (DiscoveryManagement)init.thisConfig.getEntry
                                                    (COMPONENT_NAME,
                                                     "discoveryManager",
                                                     DiscoveryManagement.class);
             } catch(NoSuchEntryException e) { /* use default */
-                discMgr = new LookupDiscoveryManager
-                                   (new String[] {""}, null, null, thisConfig);
+                init.discMgr = new LookupDiscoveryManager
+                                   (new String[] {""}, null, null, init.thisConfig);
             }
 	}//endif
-	discMgr.addDiscoveryListener(discMgrListener);
+        return init;
     }//end init
 
 

Copied: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/RFC3986URLClassLoader.java (from r1476991, river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/URLClassLoader.java)
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/RFC3986URLClassLoader.java?p2=river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/RFC3986URLClassLoader.java&p1=river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/URLClassLoader.java&r1=1476991&r2=1477969&rev=1477969&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/URLClassLoader.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/RFC3986URLClassLoader.java Wed May  1 12:17:33 2013
@@ -43,7 +43,6 @@ import java.security.CodeSource;
 import java.security.Permission;
 import java.security.PermissionCollection;
 import java.security.PrivilegedAction;
-import java.security.SecureClassLoader;
 import java.security.cert.Certificate;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -73,7 +72,7 @@ import org.apache.river.impl.Messages;
  * URLs contained in the URL search list.
  * <p>
  * Unlike java.net.URLClassLoader, CodeSource equality is based on Certificate
- * and Uri location equality, not URL.equals().
+ * and RFC3986 Uri location equality, not URL.equals().
  * <p>
  * This allows implementors of {@link java.rmi.Remote} to do two things:
  * <ol>
@@ -83,7 +82,7 @@ import org.apache.river.impl.Messages;
  * </ol>
  * 
  */
-public class URLClassLoader extends java.net.URLClassLoader {
+public class RFC3986URLClassLoader extends java.net.URLClassLoader {
 
     private final List<URL> originalUrls; // Copy on Write
 
@@ -95,18 +94,18 @@ public class URLClassLoader extends java
 
     private final URLStreamHandlerFactory factory;
 
-    private volatile AccessControlContext currentContext;
+    private final AccessControlContext currentContext;
 
-    static class SubURLClassLoader extends URLClassLoader {
+    private static class SubURLClassLoader extends RFC3986URLClassLoader {
         // The subclass that overwrites the loadClass() method
         private boolean checkingPackageAccess = false;
 
-        SubURLClassLoader(URL[] urls) {
-            super(urls, ClassLoader.getSystemClassLoader());
+        SubURLClassLoader(URL[] urls, AccessControlContext context) {
+            super(urls, ClassLoader.getSystemClassLoader(), null, context);
         }
 
-        SubURLClassLoader(URL[] urls, ClassLoader parent) {
-            super(urls, parent);
+        SubURLClassLoader(URL[] urls, ClassLoader parent, AccessControlContext context) {
+            super(urls, parent, null, context);
         }
 
         /**
@@ -142,7 +141,7 @@ public class URLClassLoader extends java
         }
     }
 
-    static class IndexFile {
+    private static class IndexFile {
 
         private final HashMap<String, ArrayList<URL>> map;
         //private URLClassLoader host;
@@ -238,18 +237,21 @@ public class URLClassLoader extends java
         }
     }
 
-    class URLHandler {
+    private static class URLHandler {
         final URL url;
         final URL codeSourceUrl;
+        final RFC3986URLClassLoader loader;
 
-        public URLHandler(URL url) {
+        public URLHandler(URL url, RFC3986URLClassLoader loader) {
             this.url = url;
             this.codeSourceUrl = url;
+            this.loader = loader;
         }
         
-        public URLHandler(URL url, URL codeSourceUrl){
+        public URLHandler(URL url, URL codeSourceUrl, RFC3986URLClassLoader loader){
             this.url = url;
             this.codeSourceUrl = codeSourceUrl;
+            this.loader = loader;
         }
 
         void findResources(String name, ArrayList<URL> resources) {
@@ -289,9 +291,9 @@ public class URLClassLoader extends java
             }
             if (packageName != null) {
                 String packageDotName = packageName.replace('/', '.');
-                Package packageObj = getPackage(packageDotName);
+                Package packageObj = loader.getPackage(packageDotName);
                 if (packageObj == null) {
-                    definePackage(packageDotName, null, null,
+                    loader.definePackage(packageDotName, null, null,
                             null, null, null, null, null);
                 } else {
                     if (packageObj.isSealed()) {
@@ -300,7 +302,7 @@ public class URLClassLoader extends java
                     }
                 }
             }
-            return defineClass(origName, clBuf, 0, clBuf.length, new UriCodeSource(codeSourceUrl, (Certificate[]) null, null));
+            return loader.defineClass(origName, clBuf, 0, clBuf.length, new UriCodeSource(codeSourceUrl, (Certificate[]) null, null));
         }
 
         URL findResource(String name) {
@@ -344,22 +346,22 @@ public class URLClassLoader extends java
 
     }
 
-    class URLJarHandler extends URLHandler {
+    private static class URLJarHandler extends URLHandler {
         private final JarFile jf;
         private final String prefixName;
         private final IndexFile index;
         private final Map<Uri, URLHandler> subHandlers = new HashMap<Uri, URLHandler>();
 
-        public URLJarHandler(URL url, URL jarURL, JarFile jf, String prefixName) {
-            super(url, jarURL);
+        public URLJarHandler(URL url, URL jarURL, JarFile jf, String prefixName, RFC3986URLClassLoader loader) {
+            super(url, jarURL, loader);
             this.jf = jf;
             this.prefixName = prefixName;
             final JarEntry je = jf.getJarEntry("META-INF/INDEX.LIST"); //$NON-NLS-1$
             this.index = (je == null ? null : IndexFile.readIndexFile(jf, je, url));
         }
 
-        public URLJarHandler(URL url, URL jarURL, JarFile jf, String prefixName, IndexFile index) {
-            super(url, jarURL);
+        public URLJarHandler(URL url, URL jarURL, JarFile jf, String prefixName, IndexFile index, RFC3986URLClassLoader loader) {
+            super(url, jarURL, loader);
             this.jf = jf;
             this.prefixName = prefixName;
             this.index = index;
@@ -457,19 +459,19 @@ public class URLClassLoader extends java
             }
             if (packageName != null) {
                 String packageDotName = packageName.replace('/', '.');
-                Package packageObj = getPackage(packageDotName);
+                Package packageObj = loader.getPackage(packageDotName);
                 if (packageObj == null) {
                     if (manifest != null) {
-                        definePackage(packageDotName, manifest,
+                        loader.definePackage(packageDotName, manifest,
                                 codeSourceUrl);
                     } else {
-                        definePackage(packageDotName, null, null,
+                        loader.definePackage(packageDotName, null, null,
                                 null, null, null, null, null);
                     }
                 } else {
                     boolean exception = packageObj.isSealed();
                     if (manifest != null) {
-                        if (isSealed(manifest, packageName + "/")) {
+                        if (loader.isSealed(manifest, packageName + "/")) {
                             exception = !packageObj
                                     .isSealed(codeSourceUrl);
                         }
@@ -481,7 +483,7 @@ public class URLClassLoader extends java
                 }
             }
             CodeSource codeS = new UriCodeSource(codeSourceUrl, entry.getCertificates(),null);
-            return defineClass(origName, clBuf, 0, clBuf.length, codeS);
+            return loader.defineClass(origName, clBuf, 0, clBuf.length, codeS);
         }
 
         URL findResourceInOwn(String name) {
@@ -528,7 +530,7 @@ public class URLClassLoader extends java
             try {
                 key = Uri.urlToUri(url);
             } catch (URISyntaxException ex) {
-                Logger.getLogger(URLClassLoader.class.getName()).log(Level.SEVERE, null, ex);
+                Logger.getLogger(RFC3986URLClassLoader.class.getName()).log(Level.SEVERE, null, ex);
             }
             synchronized (subHandlers){
                 URLHandler sub = subHandlers.get(key);
@@ -537,11 +539,11 @@ public class URLClassLoader extends java
                 }
                 String protocol = url.getProtocol();
                 if (protocol.equals("jar")) { //$NON-NLS-1$
-                    sub = createURLJarHandler(url);
+                    sub = loader.createURLJarHandler(url);
                 } else if (protocol.equals("file")) { //$NON-NLS-1$
                     sub = createURLSubJarHandler(url);
                 } else {
-                    sub = createURLHandler(url);
+                    sub = loader.createURLHandler(url);
                 }
                 if (sub != null && key != null) {
                     subHandlers.put(key, sub);
@@ -571,7 +573,7 @@ public class URLClassLoader extends java
                         "jar", "", //$NON-NLS-1$ //$NON-NLS-2$
                         jarURL.toExternalForm() + "!/").openConnection(); //$NON-NLS-1$
                 JarFile jf = juc.getJarFile();
-                URLJarHandler jarH = new URLJarHandler(url, jarURL, jf, prefixName, null);
+                URLJarHandler jarH = new URLJarHandler(url, jarURL, jf, prefixName, loader);
                 // TODO : to think what we should do with indexes & manifest.class file here
                 return jarH;
             } catch (IOException e) {
@@ -581,11 +583,11 @@ public class URLClassLoader extends java
 
     }
 
-    class URLFileHandler extends URLHandler {
+    private static class URLFileHandler extends URLHandler {
         private final String prefix;
 
-        public URLFileHandler(URL url) {
-            super(url);
+        public URLFileHandler(URL url, RFC3986URLClassLoader loader) {
+            super(url, null);
             String baseFile = url.getFile();
             String host = url.getHost();
             int hostLength = 0;
@@ -722,7 +724,7 @@ public class URLClassLoader extends java
      *             checkCreateClassLoader()} method doesn't allow creation of
      *             new ClassLoaders.
      */
-    public URLClassLoader(URL[] urls) {
+    public RFC3986URLClassLoader(URL[] urls) {
         this(urls, ClassLoader.getSystemClassLoader(), null);
     }
 
@@ -741,7 +743,7 @@ public class URLClassLoader extends java
      *             checkCreateClassLoader()} method doesn't allow creation of
      *             new class loaders.
      */
-    public URLClassLoader(URL[] urls, ClassLoader parent) {
+    public RFC3986URLClassLoader(URL[] urls, ClassLoader parent) {
         this(urls, parent, null);
     }
 
@@ -907,14 +909,14 @@ public class URLClassLoader extends java
      *            URLClassloader}.
      * @return the created {@code URLClassLoader} instance.
      */
-    public static URLClassLoader newInstance(final URL[] urls) {
-        URLClassLoader sub = AccessController
-                .doPrivileged(new PrivilegedAction<URLClassLoader>() {
-                    public URLClassLoader run() {
-                        return new SubURLClassLoader(urls);
+    public static RFC3986URLClassLoader newInstance(final URL[] urls) {
+        final AccessControlContext context = AccessController.getContext();
+        RFC3986URLClassLoader sub = AccessController
+                .doPrivileged(new PrivilegedAction<RFC3986URLClassLoader>() {
+                    public RFC3986URLClassLoader run() {
+                        return new SubURLClassLoader(urls, context);
                     }
                 });
-        sub.currentContext = AccessController.getContext();
         return sub;
     }
 
@@ -931,15 +933,15 @@ public class URLClassLoader extends java
      *            URLClassloader.
      * @return the created {@code URLClassLoader} instance.
      */
-    public static URLClassLoader newInstance(final URL[] urls,
+    public static RFC3986URLClassLoader newInstance(final URL[] urls,
                                              final ClassLoader parentCl) {
-        URLClassLoader sub = AccessController
-                .doPrivileged(new PrivilegedAction<URLClassLoader>() {
-                    public URLClassLoader run() {
-                        return new SubURLClassLoader(urls, parentCl);
+        final AccessControlContext context = AccessController.getContext();
+        RFC3986URLClassLoader sub = AccessController
+                .doPrivileged(new PrivilegedAction<RFC3986URLClassLoader>() {
+                    public RFC3986URLClassLoader run() {
+                        return new SubURLClassLoader(urls, parentCl, context);
                     }
                 });
-        sub.currentContext = AccessController.getContext();
         return sub;
     }
 
@@ -963,12 +965,20 @@ public class URLClassLoader extends java
      *             checkCreateClassLoader()} method doesn't allow creation of
      *             new {@code ClassLoader}s.
      */
-    public URLClassLoader(URL[] searchUrls, ClassLoader parent,
+    public RFC3986URLClassLoader(URL[] searchUrls, ClassLoader parent,
                           URLStreamHandlerFactory factory) {
+        this(searchUrls, parent, factory, AccessController.getContext());
+    }
+    
+    RFC3986URLClassLoader( URL[] searchUrls, 
+                            ClassLoader parent, 
+                            URLStreamHandlerFactory factory, 
+                            AccessControlContext context)
+    {
         super(searchUrls, parent, factory);  // ClassLoader protectes against finalizer attack.
         this.factory = factory;
         // capture the context of the thread that creates this URLClassLoader
-        currentContext = AccessController.getContext();
+        currentContext = context;
         int nbUrls = searchUrls.length;
         List<URL> originalUrls = new ArrayList<URL>(nbUrls);
         handlerList = new ArrayList<URLHandler>(nbUrls);
@@ -1115,7 +1125,7 @@ public class URLClassLoader extends java
             try {
                 candidateKey = Uri.urlToUri(nextCandidate);
             } catch (URISyntaxException ex) {
-                Logger.getLogger(URLClassLoader.class.getName()).log(Level.SEVERE, null, ex);
+                Logger.getLogger(RFC3986URLClassLoader.class.getName()).log(Level.SEVERE, null, ex);
             }
             if (!handlerMap.containsKey(candidateKey)) {
                 URLHandler result;
@@ -1137,11 +1147,11 @@ public class URLClassLoader extends java
     }
 
     private URLHandler createURLHandler(URL url) {
-        return new URLHandler(url);
+        return new URLHandler(url, this);
     }
 
     private URLHandler createURLFileHandler(URL url) {
-        return new URLFileHandler(url);
+        return new URLFileHandler(url, this);
     }
 
     private URLHandler createURLJarHandler(URL url) {
@@ -1165,7 +1175,7 @@ public class URLClassLoader extends java
                     "jar", "", //$NON-NLS-1$ //$NON-NLS-2$
                     jarURL.toExternalForm() + "!/").openConnection(); //$NON-NLS-1$
             JarFile jf = juc.getJarFile();
-            URLJarHandler jarH = new URLJarHandler(url, jarURL, jf, prefixName);
+            URLJarHandler jarH = new URLJarHandler(url, jarURL, jf, prefixName, this);
 
             if (jarH.getIndex() == null) {
                 try {

Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/Uri.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/Uri.java?rev=1477969&r1=1477968&r2=1477969&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/Uri.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/net/Uri.java Wed May  1 12:17:33 2013
@@ -1083,7 +1083,6 @@ public final class Uri implements Compar
 //            return false;
 //        }
 
-        /* Certificates can safely be ignored, they're checked by CertificateGrant */
         
         // javadoc:2
         // with a comment: the javadoc says only about certificates and does 
@@ -1168,7 +1167,7 @@ public final class Uri implements Compar
                     }
                     if (!hostNameMatches) return false; // else continue.
                     
-                    /* Don't want to try resolving URIGrant, it either has a
+                    /* Don't want to try resolving URI with DNS, it either has a
                      * matching host or it doesn't.
                      * 
                      * The following section is for resolving hosts, it is
@@ -1176,7 +1175,7 @@ public final class Uri implements Compar
                      * purposes only.
                      * 
                      * Not only is it expensive to perform DNS resolution, hence
-                     * the creation of URIGrant, but a CodeSource.implies
+                     * the creation of Uri, but a CodeSource.implies
                      * may also require another SocketPermission which may 
                      * cause the policy to get stuck in an endless loop, since it
                      * doesn't perform the implies in priviledged mode, it might

Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/DefaultPolicyParser.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/DefaultPolicyParser.java?rev=1477969&r1=1477968&r2=1477969&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/DefaultPolicyParser.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/DefaultPolicyParser.java Wed May  1 12:17:33 2013
@@ -25,13 +25,10 @@ package org.apache.river.api.security;
 import org.apache.river.impl.Messages;
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
-import org.apache.river.impl.net.UriString;
 import java.io.BufferedReader;
-import java.io.File;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
-import java.net.URI;
 import java.net.URL;
 import java.security.cert.Certificate;
 import java.security.cert.CertificateException;
@@ -51,6 +48,7 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
 
+import org.apache.river.api.net.Uri;
 import org.apache.river.api.security.DefaultPolicyScanner.GrantEntry;
 import org.apache.river.api.security.DefaultPolicyScanner.KeystoreEntry;
 import org.apache.river.api.security.DefaultPolicyScanner.PermissionEntry;
@@ -265,7 +263,7 @@ class DefaultPolicyParser implements Pol
         // We do this to support windows, this is to ensure that path
         // capitalisation is correct and illegal strings are escaped correctly.
         if (uriString == null) return null;
-        return UriString.fixWindowsURI(uriString);
+        return Uri.fixWindowsURI(uriString);
     }
     
     Segment segment(String s, Properties p) throws ExpansionFailedException{

Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/PolicyUtils.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/PolicyUtils.java?rev=1477969&r1=1477968&r2=1477969&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/PolicyUtils.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/PolicyUtils.java Wed May  1 12:17:33 2013
@@ -41,13 +41,10 @@ import java.security.PrivilegedException
 import java.security.Security;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.apache.river.impl.net.UriString;
+import org.apache.river.api.net.Uri;
 
 /**
  * This class consist of a number of static methods, which provide a common functionality 
@@ -213,18 +210,17 @@ import org.apache.river.impl.net.UriStri
                         // codebase is "file:"
                         path = "*";
                     }
-                    return UriString.normalisation(filePathToURI(new File(path)
-                            .getAbsolutePath()));
+                    return Uri.uriToURI(Uri.fileToUri(new File(path)));
                 } else {
                     // codebase is "file://<smth>"
-                    return UriString.normalisation(codebase.toURI());
+                    return Uri.uriToURI(Uri.urlToUri(codebase));
                 }
             } catch (Exception e) {
                 if ( e instanceof SecurityException ) throw (SecurityException) e;
                 // Ignore
             }
         }
-        return UriString.normalisation(codebase.toURI());
+        return Uri.uriToURI(Uri.urlToUri(codebase));
     }
 
     /**

Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/URIGrant.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/URIGrant.java?rev=1477969&r1=1477968&r2=1477969&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/URIGrant.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/api/security/URIGrant.java Wed May  1 12:17:33 2013
@@ -20,14 +20,11 @@ package org.apache.river.api.security;
 
 import java.io.InvalidObjectException;
 import java.io.ObjectInputStream;
-import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.security.AccessController;
 import java.security.CodeSource;
 import java.security.Permission;
 import java.security.Principal;
-import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.security.cert.Certificate;
 import java.util.ArrayList;
@@ -37,7 +34,6 @@ import java.util.Iterator;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import org.apache.river.api.net.Uri;
-import org.apache.river.impl.net.UriString;
 
 /**
  *
@@ -139,285 +135,12 @@ class URIGrant extends CertificateGrant 
         } catch (URISyntaxException ex) {
             Logger.getLogger(URIGrant.class.getName()).log(Level.SEVERE, null, ex);
         }
-//        try {
-//            implied = AccessController.doPrivileged(new NormaliseURLAction(url));
-//        } catch (PrivilegedActionException ex) {
-//            Exception cause = ex.getException();
-//            cause.printStackTrace(System.err);
-//            return false;
-//        }
         for (int i = 0; i<l ; i++){
             if (uris[i].implies(implied)) return true;
         }
         return false;
     }
     
-    /* This section of code was copied from Apache Harmony's CodeSource
-     * SVN Revision 929252
-     * 
-     * 
-     * Indicates whether the specified code source is implied by this {@code
-     * URI}. Returns {@code true} if all of the following conditions are
-     * {@code true}, otherwise {@code false}:
-     * <p>
-     * <ul>
-     * <li>{@code cs} is not {@code null}
-     * <li>if this {@code CodeSource}'s location is not {@code null}, the
-     * following conditions are checked
-     * <ul>
-     * <li>this {@code CodeSource}'s location is not {@code null}
-     * <li>this {@code CodeSource}'s location protocol is equal to {@code cs}'s
-     * location protocol
-     * <li>if this {@code CodeSource}'s location host is not {@code null}, the
-     * following conditions are checked
-     * <ul>
-     * <li>{@code cs}'s host is not {@code null}
-     * <li>the wildcard or partial wildcard of this {@code URI}'s
-     * host matches {@code cs}'s location host.
-     * </ul>
-     * <li>if this {@code CodeSource}'s location port != -1 the port of {@code
-     * cs}'s location is equal to this {@code CodeSource}'s location port
-     * <li>this {@code CodeSource}'s location file matches {@code cs}'s file
-     * whereas special wildcard matching applies as described below
-     * <li>this {@code CodeSource}'s location reference is equal to to {@code
-     * cs}'s location reference
-     * </ul>
-     * </ul>
-     * <p>
-     * Note: If this {@code CodeSource} has a {@code null} location,
-     * this method returns {@code true}.
-     * <p>
-     * Matching rules for the {@code CodeSource}'s location file:
-     * <ul>
-     * <li>if this {@code CodeSource}'s location file ends with {@code "/-"},
-     * then {@code cs}'s file must start with {@code CodeSource}'s location file
-     * (exclusive the trailing '-')
-     * <li>if this {@code CodeSource}'s location file ends with {@code "/*"},
-     * then {@code cs}'s file must start with {@code CodeSource}'s location file
-     * (exclusive the trailing '*') and must not have any further '/'
-     * <li>if this {@code CodeSource}'s location file ends with {@code "/"},
-     * then {@code cs}'s file must start with {@code CodeSource}'s location file
-     * <li>if this {@code CodeSource}'s location file does not end with {@code
-     * "/"}, then {@code cs}'s file must start with {@code CodeSource}'s
-     * location file with the '/' appended to it.
-     * </ul>
-     * Examples for locations that imply the location
-     * "http://harmony.apache.org/milestones/M9/apache-harmony.jar":
-     *
-     * <pre>
-     * http:
-     * http://&#42;/milestones/M9/*
-     * http://*.apache.org/milestones/M9/*
-     * http://harmony.apache.org/milestones/-
-     * http://harmony.apache.org/milestones/M9/apache-harmony.jar
-     * </pre>
-     *
-     * @param cs
-     *            the code source to check.
-     * @return {@code true} if the argument code source is implied by this
-     *         {@code CodeSource}, otherwise {@code false}.
-     */
-    final boolean implies(Uri grant, Uri implied) { // package private for junit
-        //
-        // Here, javadoc:N refers to the appropriate item in the API spec for 
-        // the CodeSource.implies()
-        // The info was taken from the 1.5 final API spec
-
-        // javadoc:1
-//        if (cs == null) {
-//            return false;
-//        }
-
-        /* Certificates can safely be ignored, they're checked by CertificateGrant */
-        
-        // javadoc:2
-        // with a comment: the javadoc says only about certificates and does 
-        // not explicitly mention CodeSigners' certs.
-        // It seems more convenient to use getCerts() to get the real 
-        // certificates - with a certificates got form the signers
-//        Certificate[] thizCerts = getCertificatesNoClone();
-//        if (thizCerts != null) {
-//            Certificate[] thatCerts = cs.getCertificatesNoClone();
-//            if (thatCerts == null
-//                    || !PolicyUtils.matchSubset(thizCerts, thatCerts)) {
-//                return false;
-//            }
-//        }
-
-        // javadoc:3
-        if (grant != null) {
-            
-            //javadoc:3.1
-//            URL otherURL = cs.getLocation();
-//            if ( otherURL == null) {
-//                return false;
-//            }
-//            URI otherURI;
-//            try {
-//                otherURI = otherURL.toURI();
-//            } catch (URISyntaxException ex) {
-//                return false;
-//            }
-            //javadoc:3.2
-            if (grant.equals(implied)) {
-                return true;
-            }
-            //javadoc:3.3
-            if (!grant.getScheme().equals(implied.getScheme())) {
-                return false;
-            }
-            //javadoc:3.4
-            String thisHost = grant.getHost();
-            if (thisHost != null) {
-                String thatHost = implied.getHost();
-                if (thatHost == null) {
-                    return false;
-                }
-
-                // 1. According to the spec, an empty string will be considered 
-                // as "localhost" in the SocketPermission
-                // 2. 'file://' URLs will have an empty getHost()
-                // so, let's make a special processing of localhost-s, I do 
-                // believe this'll improve performance of file:// code sources 
-
-                //
-                // Don't have to evaluate both the boolean-s each time.
-                // It's better to evaluate them directly under if() statement.
-                // 
-                // boolean thisIsLocalHost = thisHost.length() == 0 || "localhost".equals(thisHost);
-                // boolean thatIsLocalHost = thatHost.length() == 0 || "localhost".equals(thatHost);
-                // 
-                // if( !(thisIsLocalHost && thatIsLocalHost) &&
-                // !thisHost.equals(thatHost)) {
-
-                if (!((thisHost.length() == 0 || "localhost".equals(thisHost)) && (thatHost //$NON-NLS-1$
-                        .length() == 0 || "localhost".equals(thatHost))) //$NON-NLS-1$
-                        && !thisHost.equals(thatHost)) {
-                    
-                    // Do wildcard matching here to replace SocketPermission functionality.
-                    // This section was copied from Apache Harmony SocketPermission
-                    boolean hostNameMatches = false;
-                    boolean isPartialWild = (thisHost.charAt(0) == '*');
-                    if (isPartialWild) {
-                        boolean isWild = (thisHost.length() == 1);
-                        if (isWild) {
-                            hostNameMatches = true;
-                        } else {
-                            // Check if thisHost matches the end of thatHost after the wildcard
-                            int length = thisHost.length() - 1;
-                            hostNameMatches = thatHost.regionMatches(thatHost.length() - length,
-                                    thisHost, 1, length);
-                        }
-                    }
-                    if (!hostNameMatches) return false; // else continue.
-                    
-                    /* Don't want to try resolving URIGrant, it either has a
-                     * matching host or it doesn't.
-                     * 
-                     * The following section is for resolving hosts, it is
-                     * not relevant here, but has been preserved for information
-                     * purposes only.
-                     * 
-                     * Not only is it expensive to perform DNS resolution, hence
-                     * the creation of URIGrant, but a CodeSource.implies
-                     * may also require another SocketPermission which may 
-                     * cause the policy to get stuck in an endless loop, since it
-                     * doesn't perform the implies in priviledged mode, it might
-                     * also allow an attacker to substitute one codebase for
-                     * another using a dns cache poisioning attack.  In any case
-                     * the DNS cannot be assumed trustworthy enough to supply
-                     * the policy with information at this level. The implications
-                     * are greater than the threat posed by SocketPermission
-                     * which simply allows a network connection, as this may
-                     * apply to any Permission, even AllPermission.
-                     * 
-                     * Typically the URI of the codebase will be a match for
-                     * the codebase annotation string that is stored as a URL
-                     * in CodeSource, then converted to a URI for comparison.
-                     */
-
-                    // Obvious, but very slow way....
-                    // 
-                    // SocketPermission thisPerm = new SocketPermission(
-                    //          this.location.getHost(), "resolve");
-                    // SocketPermission thatPerm = new SocketPermission(
-                    //          cs.location.getHost(), "resolve");
-                    // if (!thisPerm.implies(thatPerm)) { 
-                    //      return false;
-                    // }
-                    //
-                    // let's cache it: 
-
-//                    if (this.sp == null) {
-//                        this.sp = new SocketPermission(thisHost, "resolve"); //$NON-NLS-1$
-//                    }
-//
-//                    if (cs.sp == null) {
-//                        cs.sp = new SocketPermission(thatHost, "resolve"); //$NON-NLS-1$
-//                    } 
-//
-//                    if (!this.sp.implies(cs.sp)) {
-//                        return false;
-//                    }
-                    
-                } // if( ! this.location.getHost().equals(cs.location.getHost())
-            } // if (this.location.getHost() != null)
-
-            //javadoc:3.5
-            if (grant.getPort() != -1) {
-                if (grant.getPort() != implied.getPort()) {
-                    return false;
-                }
-            }
-
-            //javadoc:3.6
-            // compatbility with URL.getFile
-            String thisFile = grant.getPath();
-            String thatFile = implied.getPath();
-            if (thatFile == null || thisFile == null) return false;
-            if (thisFile.endsWith("/-")) { //javadoc:3.6."/-" //$NON-NLS-1$
-                if (!thatFile.startsWith(thisFile.substring(0, thisFile
-                        .length() - 2))) {
-                    return false;
-                }
-            } else if (thisFile.endsWith("/*")) { //javadoc:3.6."/*" //$NON-NLS-1$
-                if (!thatFile.startsWith(thisFile.substring(0, thisFile
-                        .length() - 2))) {
-                    return false;
-                }
-                // no further separators(s) allowed
-                if (thatFile.indexOf("/", thisFile.length() - 1) != -1) { //$NON-NLS-1$
-                    return false;
-                }
-            } else {
-                // javadoc:3.6."/"
-                if (!thisFile.equals(thatFile)) {
-                    if (!thisFile.endsWith("/")) { //$NON-NLS-1$
-                        if (!thatFile.equals(thisFile + "/")) { //$NON-NLS-1$
-                            return false;
-                        }
-                    } else {
-                        return false;
-                    }
-                }
-            }
-            
-            //javadoc:3.7
-            // A URL Anchor is a URI Fragment.
-            if (grant.getFragment() != null) {
-                if (!grant.getFragment().equals(implied.getFragment())) {
-                    return false;
-                }
-            }
-            // ok, every check was made, and they all were successful. 
-            // it's ok to return true.
-        } // if this.location != null
-
-        // javadoc: a note about CodeSource with null location and null Certs 
-        // is applicable here 
-        return true;
-    }
-    
     @Override
     public PermissionGrantBuilder getBuilderTemplate() {
         PermissionGrantBuilder pgb = super.getBuilderTemplate();

Modified: river/jtsk/skunk/qa_refactor/trunk/test/src/com/sun/jini/jeri/internal/mux/MuxStartTimeoutTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/test/src/com/sun/jini/jeri/internal/mux/MuxStartTimeoutTest.java?rev=1477969&r1=1477968&r2=1477969&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/test/src/com/sun/jini/jeri/internal/mux/MuxStartTimeoutTest.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/test/src/com/sun/jini/jeri/internal/mux/MuxStartTimeoutTest.java Wed May  1 12:17:33 2013
@@ -72,7 +72,7 @@ public class MuxStartTimeoutTest {
                 }
             });
             t.start();
-            t.join(20000);
+            t.join(35000);
             assertTrue(finished.get());
             assertFalse(succeeded.get());
             assertTrue(failed.get());

Modified: river/jtsk/skunk/qa_refactor/trunk/test/src/com/sun/jini/outrigger/FastListTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/test/src/com/sun/jini/outrigger/FastListTest.java?rev=1477969&r1=1477968&r2=1477969&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/test/src/com/sun/jini/outrigger/FastListTest.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/test/src/com/sun/jini/outrigger/FastListTest.java Wed May  1 12:17:33 2013
@@ -9,6 +9,7 @@ import java.util.List;
 import java.util.concurrent.BrokenBarrierException;
 import java.util.concurrent.CyclicBarrier;
 
+import java.util.concurrent.atomic.AtomicInteger;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -19,11 +20,11 @@ import org.junit.Test;
 public class FastListTest {
 
     /** The FastList under test. */
-    private FastList<TestNode> testee;
+    private volatile FastList<TestNode> testee;
     /** Convenience Iterable that gives access to testee's raw data. */
-    private Iterable<TestNode> rawTestee;
+    private volatile Iterable<TestNode> rawTestee;
     /** Next id to use in creating data. */
-    int nextId = 0;
+    final AtomicInteger nextId = new AtomicInteger();
 
     @Before
     public void initialize() {
@@ -281,8 +282,7 @@ public class FastListTest {
     private List<TestNode> makeDataList(int size) {
         List<TestNode> l = new ArrayList<TestNode>();
         for (int i = 0; i < size; i++) {
-            l.add(new TestNode(nextId));
-            nextId++;
+            l.add(new TestNode(nextId.getAndIncrement()));
         }
         return l;
     }
@@ -486,7 +486,7 @@ public class FastListTest {
                     + super.toString() + "]";
         }
 
-        int id;
+        final int id;
 
         private TestNode(int id) {
             this.id = id;

Modified: river/jtsk/skunk/qa_refactor/trunk/test/src/com/sun/jini/outrigger/TxnTableTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/test/src/com/sun/jini/outrigger/TxnTableTest.java?rev=1477969&r1=1477968&r2=1477969&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/test/src/com/sun/jini/outrigger/TxnTableTest.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/test/src/com/sun/jini/outrigger/TxnTableTest.java Wed May  1 12:17:33 2013
@@ -47,29 +47,26 @@ public class TxnTableTest extends TestCa
 	@SuppressWarnings("unchecked")
 	public void testKeyEquals() throws Exception {
 		
-		TxnTable mockTxnTable = mock(TxnTable.class);
+//		TxnTable mockTxnTable = mock(TxnTable.class);
 		
 		TransactionManager mockTransactionManager = mock(TransactionManager.class);
 		
 		final long id = 1000L;
 		final boolean isPrepared = true;
 		
-		Object key = createKeyInstance(mockTxnTable,
-									   mockTransactionManager, 
-									   id, 
-									   isPrepared);
-		
-		Object equalKey = createKeyInstance(mockTxnTable,
-											mockTransactionManager, 
-											id, 
-											isPrepared);
+		Object key = createKeyInstance(mockTransactionManager, 
+                                               id, 
+                                               isPrepared);
+		
+		Object equalKey = createKeyInstance(mockTransactionManager, 
+                                                    id, 
+                                                    isPrepared);
 		
 		assertTrue("These keys should be equal", key.equals(equalKey));
 		
-		Object notPrepared = createKeyInstance(mockTxnTable,
-							  				   mockTransactionManager, 
-											   id, 
-											   !isPrepared);
+		Object notPrepared = createKeyInstance(mockTransactionManager, 
+                                                       id, 
+                                                       !isPrepared);
 		
 		//the following assertion reveals the bug
 		assertTrue("Although not prepared, it's manager is the same and should therefore be equal", key.equals(notPrepared));
@@ -80,25 +77,30 @@ public class TxnTableTest extends TestCa
 		} catch (AssertionError ae) {}
 	}
 
-	private Object createKeyInstance(TxnTable mockTxnTable,
-									  TransactionManager mockTransactionManager, 
-									  final long firstId,
-									 final boolean isPrepared) throws NoSuchMethodException,
-									 									InstantiationException, 
-									 									IllegalAccessException,
-									 									InvocationTargetException {
-		
-		Constructor innerKeyCntr = innerKey.getDeclaredConstructor(new Class[] { TxnTable.class,
-																				  TransactionManager.class,
-														        				  long.class,
-																        		  boolean.class });
+        // Note that TxnTable.Key is now a static class instead of an instance
+        // class, so the TxnTable "this" reference is no longer needed.
+	private Object createKeyInstance(TransactionManager mockTransactionManager, 
+                                  final long firstId,
+                                 final boolean isPrepared) 
+                throws NoSuchMethodException,
+                        InstantiationException, 
+                        IllegalAccessException,
+                        InvocationTargetException {
+		
+		Constructor innerKeyCntr = innerKey.getDeclaredConstructor(
+                        new Class[] { TransactionManager.class,
+                            long.class,
+                            boolean.class });
+                
 		assertNotNull("Sanity failed", innerKeyCntr);
 		
 		innerKeyCntr.setAccessible(true);
-		Object instance = innerKeyCntr.newInstance(new Object[] {mockTxnTable, 
-																  mockTransactionManager,
-																  firstId,
-																  isPrepared} );
+		Object instance = innerKeyCntr.newInstance(
+                        new Object[] {
+//                            mockTxnTable, 
+                                  mockTransactionManager,
+                                  firstId,
+                                  isPrepared} );
 		
 		assertNotNull("Sanity failed", instance);
 		



Mime
View raw message