river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter_firmst...@apache.org
Subject svn commit: r1444526 - in /river/jtsk/skunk/qa_refactor/trunk/src: net/jini/discovery/LookupDiscovery.java net/jini/loader/pref/PreferredClassLoader.java net/jini/loader/pref/PreferredClassProvider.java org/apache/river/impl/net/UriString.java
Date Sun, 10 Feb 2013 10:43:45 GMT
Author: peter_firmstone
Date: Sun Feb 10 10:43:44 2013
New Revision: 1444526

URL: http://svn.apache.org/r1444526
Log:
JTREG test updates::

UriString fix for directory URL paths intended for URLClassLoader

Replace reference-collections with custard-apple (same library, later version) to fix ThreadFactory
permission issue.

Replace Cliff Click's NonBlockingHashMap with ConcurrenHashMap in PreferredClassProvider to
avoid some minor permission issues with unprivileged code.

Added additional logging to PreferredClassProvider.

Added permissions to some jtreg test policy files for new code where applicable.

JIni Standards Documentation updates:

Added JavaSpace05 to specification.

Modified:
    river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/LookupDiscovery.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/org/apache/river/impl/net/UriString.java

Modified: river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/LookupDiscovery.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/LookupDiscovery.java?rev=1444526&r1=1444525&r2=1444526&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/LookupDiscovery.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/net/jini/discovery/LookupDiscovery.java Sun Feb
10 10:43:44 2013
@@ -1727,7 +1727,7 @@ public class LookupDiscovery implements 
      *  disappears prior to the commencement of the unicast discovery stage.
      */
     private class UnicastDiscoveryTask implements TaskManager.Task {
-	private Object req;
+	private final Object req;
 	private Ticket ticket = null;
 	private boolean delayRun = false;
 	UnicastDiscoveryTask(Object req) {

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=1444526&r1=1444525&r2=1444526&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
Sun Feb 10 10:43:44 2013
@@ -41,7 +41,6 @@ import java.security.PermissionCollectio
 import java.security.Permissions;
 import java.security.ProtectionDomain;
 import java.security.Policy;
-import java.security.Principal;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
@@ -592,8 +591,9 @@ public class PreferredClassLoader extend
 	     * available upon the attempt (elsewhere) to obtain the preferred
 	     * list
 	     */
-            URL baseURL = getBaseJarURL(firstURL);
+            URL baseURL = null;
 	    try {
+                baseURL = getBaseJarURL(firstURL);
 		((JarURLConnection) baseURL.openConnection()).getManifest();
 		exists = true;
 	    } catch (IOException e) {
@@ -1035,21 +1035,21 @@ public class PreferredClassLoader extend
 	}
     }
     
-    protected Class<?> findClass(final String name)
-	 throws ClassNotFoundException
-    {   
-        /* TODO: Override and create our own CodeSource
-         * implementation that contains permissions.perm
-         * After we retrieve the manifest, class bytes and
-         * certificates, create the CodeSource we call
-         * defineClass(String name, byte[]b, int off, int len, CodeSource cs)
-         * 
-         * This will be utilised by a class that overrides 
-         * BasicProxyPreparer.getPermissions()
-         * to retrieve the advisory permissions.
-         */
-        return super.findClass(name);
-    }
+//    protected Class<?> findClass(final String name)
+//	 throws ClassNotFoundException
+//    {   
+//        /* TODO: Override and create our own CodeSource
+//         * implementation that contains permissions.perm
+//         * After we retrieve the manifest, class bytes and
+//         * certificates, create the CodeSource we call
+//         * defineClass(String name, byte[]b, int off, int len, CodeSource cs)
+//         * 
+//         * This will be utilised by a class that overrides 
+//         * BasicProxyPreparer.getPermissions()
+//         * to retrieve the advisory permissions.
+//         */
+//        return super.findClass(name);
+//    }
 
     /**
      * {@inheritDoc}

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=1444526&r1=1444525&r2=1444526&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
Sun Feb 10 10:43:44 2013
@@ -52,13 +52,13 @@ 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;
 import java.util.logging.Level;
 import net.jini.loader.ClassAnnotation;
 import net.jini.loader.DownloadPermission;
 import org.apache.river.impl.net.UriString;
-import org.cliffc.high_scale_lib.NonBlockingHashMap;
 
 /**
  * An <code>RMIClassLoader</code> provider that supports preferred
@@ -304,13 +304,13 @@ public class PreferredClassProvider exte
     
     static {
         ConcurrentMap<Referrer<List<URI>>,Referrer<URL[]>> intern
=
-                new NonBlockingHashMap<Referrer<List<URI>>,Referrer<URL[]>>();
+                new ConcurrentHashMap<Referrer<List<URI>>,Referrer<URL[]>>();
         urlCache = RC.concurrentMap(intern, Ref.TIME, Ref.STRONG, 10000L, 10000L);
         ConcurrentMap<Referrer<String>,Referrer<URI[]>> intern1 =
-                new NonBlockingHashMap<Referrer<String>,Referrer<URI[]>>();
+                new ConcurrentHashMap<Referrer<String>,Referrer<URI[]>>();
         uriCache = RC.concurrentMap(intern1, Ref.TIME, Ref.STRONG, 1000L, 1000L);
                 ConcurrentMap<Referrer<LoaderKey>,Referrer<ClassLoader>>
internal =
-                new NonBlockingHashMap<Referrer<LoaderKey>,Referrer<ClassLoader>>();
+                new ConcurrentHashMap<Referrer<LoaderKey>,Referrer<ClassLoader>>();
         loaderTable = RC.concurrentMap(internal, Ref.STRONG, Ref.WEAK_IDENTITY, 200L, 200L);
     }
     
@@ -364,7 +364,7 @@ public class PreferredClassProvider exte
 	}
 	this.requireDlPerm = requireDlPerm;
         ConcurrentMap<Referrer<ClassLoader>,Referrer<PermissionCollection>>
inter =
-                new NonBlockingHashMap<Referrer<ClassLoader>,Referrer<PermissionCollection>>();
+                new ConcurrentHashMap<Referrer<ClassLoader>,Referrer<PermissionCollection>>();
         classLoaderPerms = RC.concurrentMap(inter, Ref.WEAK_IDENTITY, Ref.STRONG, 200L, 200L);
 	initialized = true;
     }
@@ -1605,6 +1605,9 @@ public class PreferredClassProvider exte
 	 * with respect to the parent class loader.
 	 */
 	if (uris == null) {
+            if (logger.isLoggable(Level.FINEST)){
+                logger.log(Level.FINEST, "uri string is null, returning parent ClassLoader:
" + parent);
+            }
 	    return parent;
 	}
 
@@ -1623,6 +1626,30 @@ public class PreferredClassProvider exte
 	 * }
 	 */
         
+        if (logger.isLoggable(Level.FINEST)){
+            String uriString = null;
+            String urlString = null;
+            StringBuilder sb = new StringBuilder(120);
+            sb.append("URI[]: ");
+            int l = uris.length;
+            for (int i = 0; i < l; i++){
+                sb.append(uris[i]);
+                sb.append(" ");
+            }
+            uriString = sb.toString();
+            sb.delete(0, sb.length()-1);
+            sb.append("URL[]: ");
+            l = urls.length;
+            for (int i = 0; i <l; i++){
+                sb.append(urls[i]);
+                sb.append(" ");
+            }
+            urlString = sb.toString();
+            logger.log(Level.FINEST, uriString);
+            logger.log(Level.FINEST, urlString);
+            logger.log(Level.FINEST, "ClassLoader: {0}", parent);
+        }
+        
         /* Each LoaderKey is unique to a ClassLoader, the LoaderKey contains
          * a weak reference to the parent ClassLoader, the parent ClassLoader
          * will not be collected until all child ClassLoaders have been collected.
@@ -1664,15 +1691,28 @@ public class PreferredClassProvider exte
 
             if (loader == null) {
                 loader = createClassLoader(urls, parent, requireDlPerm);
+                if (logger.isLoggable(Level.FINEST)) {
+                    logger.log(Level.FINEST, "ClassLoader was null creating new PreferredClassLoader{0}",
loader);
+                }
                 /* RIVER-265
                  * The next section of code has been moved inside this
                  * block to avoid caching loaders found using
                  * findOriginLoader
                  */
                 ClassLoader existed = loaderTable.putIfAbsent(key, loader);
-                if (existed != null) loader = existed;
+                if (existed != null) {
+                    if (logger.isLoggable(Level.FINEST)){
+                        logger.log(Level.FINEST, "ClassLoader existed, replacing {0} with
{1}", new Object[]{loader, existed});
+                    }
+                    loader = existed;
+                }
+                
+            } else if (logger.isLoggable(Level.FINEST)) {
+                logger.log(Level.FINEST, "ClassLoader: {0}", loader);
             }
 
+        } else if (logger.isLoggable(Level.FINEST)){
+            logger.log(Level.FINEST, "ClassLoader found in loader table: {0} with key {1}",
new Object[]{loader, key});
         }
         return loader;
     }
@@ -1780,6 +1820,26 @@ public class PreferredClassProvider exte
 				  parent == other.get()))
 		&& Arrays.equals(uris, other.uris);
 	}
+        
+        public String toString(){
+            StringBuilder sb = new StringBuilder(120);
+            int l = uris.length;
+            sb.append(getClass());
+            sb.append("\n");
+            sb.append("URI[]: ");
+            for (int i = 0; i < l; i++){
+                
+            }
+            sb.append("\n");
+            if (!nullParent) {
+                sb.append("Parent ClassLoader: ");
+                sb.append(get());
+            } else {
+                sb.append("System parent ClassLoader");
+            }
+            sb.append("\n");
+            return sb.toString();
+        }
     }
 
     private static ClassLoader getClassLoader(final Class c) {

Modified: river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/impl/net/UriString.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/impl/net/UriString.java?rev=1444526&r1=1444525&r2=1444526&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/impl/net/UriString.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/org/apache/river/impl/net/UriString.java Sun Feb
10 10:43:44 2013
@@ -184,14 +184,14 @@ public class UriString {
         return sb.toString();
     }
     
-    /* Fixes windows file URI path by converting back slashes to forward
+    /** Fixes windows file URI string by converting back slashes to forward
      * slashes and inserting a forward slash before the drive letter if it is
-     * missing.  No modification of case is performed.
+     * missing.  No normalisation or modification of case is performed.
      */
-    public static String fixWindowsURI(String path) {
-        if (path == null) return null;
-        if ( path.startsWith("file:") || path.startsWith("FILE:")){
-            char [] u = path.toCharArray();
+    public static String fixWindowsURI(String uri) {
+        if (uri == null) return null;
+        if ( uri.startsWith("file:") || uri.startsWith("FILE:")){
+            char [] u = uri.toCharArray();
             int l = u.length; 
             StringBuilder sb = new StringBuilder();
             for (int i=0; i<l; i++){
@@ -200,7 +200,7 @@ public class UriString {
                     sb.append('/');
                     continue;
                 }
-                if (i == 5 && path.startsWith(":", 6 )) {
+                if (i == 5 && uri.startsWith(":", 6 )) {
                     // Windows drive letter without leading slashes doesn't comply
                     // with URI spec, fix it here
                     sb.append("/");
@@ -209,14 +209,14 @@ public class UriString {
             }
             return sb.toString();
         }
-        return path;
+        return uri;
     }
     
     /**
-     * Normalises URIs to standard ones, eliminating pathname symbols, in addition
-     * to normalisation compliant with RFC3986 this method, uses the platform specific
-     * canonical file path for "file" scheme URIs and then normalises it using
-     * RFC3986 normalisation rules.
+     * Normalises a URI, eliminating pathname symbols, in addition
+     * to normalisation compliant with RFC3986 this method, uses platform specific
+     * canonical file path for "file" scheme URIs, then normalises using
+     * RFC3986 rules.
      * 
      * This minimises false negatives for URI equals and policy based URI
      * comparison.
@@ -232,12 +232,22 @@ public class UriString {
         if ("file".equals(scheme)) { //$NON-NLS-1$
             if (codebase.getHost() == null || codebase.getHost().isEmpty()) {
                 String path = codebase.getPath();
-
+                String forwardSlash = "/";
                 if (path == null || path.length() == 0) {
                     // codebase is "file:"
                     path = "*";
                 }
-                return normalisation(filePathToURI(new File(path).getAbsolutePath()));
+                // Ensure compatibility with URLClassLoader, when directory
+                // character is dropped by File.
+                boolean directory = false;
+                if (path.endsWith(forwardSlash)) directory = true;
+                path = new File(path).getAbsolutePath();
+                if (directory) {
+                    if (! (path.endsWith(File.pathSeparator))){
+                        path = path + File.pathSeparator;
+                    }
+                }
+                return normalisation(filePathToURI(path));
             } else {
                 // codebase is "file://<smth>"
                 return normalisation(codebase);
@@ -260,7 +270,6 @@ public class UriString {
             path = path.replace(File.separatorChar, '/');
             path = path.toUpperCase(); // Windows path must be CAPITALISED during normalisation.
         }
-//        path = filePathNormalise(path);
         if (!path.startsWith("/")) { //$NON-NLS-1$
             return new URI("file", null, //$NON-NLS-1$
                     new StringBuilder(path.length() + 1).append('/')



Mime
View raw message