harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r467535 - /incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java
Date Wed, 25 Oct 2006 01:17:44 GMT
Author: ndbeyer
Date: Tue Oct 24 18:17:43 2006
New Revision: 467535

URL: http://svn.apache.org/viewvc?view=rev&rev=467535
Log:
Apply second patch from HARMONY-1936: [classlib][rmi] improper class loader creation in DefaultRMIClassLoaderSpi
due to race condition

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java?view=diff&rev=467535&r1=467534&r2=467535
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java
Tue Oct 24 18:17:43 2006
@@ -420,7 +420,7 @@
     /*
      * Finds loader in classloaders table. Returns it as a result if it's not
      * null, otherwise creates URLLoader, adds it to the table and returns it
-     * as a result.
+     * as a result. Checks persmission on found/created loader.
      *
      * @param codebase list of URLs separated by spaces
      *
@@ -446,6 +446,30 @@
                 return parentLoader;
             }
         }
+        URLLoader loader = getClassLoaderNoCheck(parentLoader, codebase);
+
+        if (loader != null) {
+            loader.checkPermissions();
+        }
+        return loader;
+    }
+    
+    /*
+     * Finds URLLoader in classloaders table. Returns it as a result if it's not
+     * null, otherwise creates URLLoader, adds it to the table and returns it
+     * as a result. Does not check permission on found/created loader.
+     *
+     * @param parentLoader parent classloader
+     * @param codebase list of URLs separated by spaces
+     *
+     * @return URLLoader found/created
+     *
+     * @throws MalformedURLException if the method was unable to parse one of
+     *         provided URLs
+     */
+    private static URLLoader getClassLoaderNoCheck(
+            ClassLoader parentLoader,
+            String codebase) throws MalformedURLException {
         TableKey key = new TableKey(parentLoader, codebase);
         URLLoader loader = null;
 
@@ -456,9 +480,6 @@
                 if (loader == null) {
                     urlLoaders.remove(key);
                 } else {
-                    if (loader != null) {
-                        loader.checkPermissions();
-                    }
                     return loader;
                 }
             }
@@ -481,12 +502,8 @@
             loader = AccessController.doPrivileged(
                     new CreateLoaderAction(key.getURLs(), parentLoader), ctx);
             urlLoaders.put(key, new WeakReference<URLLoader>(loader));
+            return loader;
         }
-
-        if (loader != null) {
-            loader.checkPermissions();
-        }
-        return loader;
     }
 
     /*



Mime
View raw message