incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r921461 - /incubator/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java
Date Wed, 10 Mar 2010 17:25:07 GMT
Author: not
Date: Wed Mar 10 17:25:07 2010
New Revision: 921461

URL: http://svn.apache.org/viewvc?rev=921461&view=rev
Log:
ARIES-237 Call ClassLoader.getParent in a doPriv code block.

Modified:
    incubator/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java

Modified: incubator/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java?rev=921461&r1=921460&r2=921461&view=diff
==============================================================================
--- incubator/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java
(original)
+++ incubator/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java
Wed Mar 10 17:25:07 2010
@@ -171,18 +171,24 @@ public final class ServiceHelper
     return result;
   }
 
-  private static BundleContext getBundleContext(ClassLoader cl)
+  private static BundleContext getBundleContext(final ClassLoader cl2)
   {
-    BundleContext result = null;
-    while (result == null && cl != null) {
-      if (cl instanceof BundleReference) {
-        result = ((BundleReference)cl).getBundle().getBundleContext();
-      } else if (cl != null) {
-        cl = cl.getParent();
+    return AccessController.doPrivileged(new PrivilegedAction<BundleContext>() {
+      public BundleContext run()
+      {
+        ClassLoader cl = cl2;
+        BundleContext result = null;
+        while (result == null && cl != null) {
+          if (cl instanceof BundleReference) {
+            result = ((BundleReference)cl).getBundle().getBundleContext();
+          } else if (cl != null) {
+            cl = cl.getParent();
+          }
+        }
+        
+        return result;
       }
-    }
-    
-    return result;
+    });
   }
 
   public static Object getService(String interface1, String filter, String serviceName, String
id, boolean dynamicRebind, Map<String, Object> env) throws NamingException



Mime
View raw message