ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject incubator-ranger git commit: Ranger-715:Fix issues reported by coverity test in Ranger Plugin ClassLoader
Date Tue, 03 Nov 2015 00:34:25 GMT
Repository: incubator-ranger
Updated Branches:
  refs/heads/master 433ab8523 -> 3e462d15f


Ranger-715:Fix issues reported by coverity test in Ranger Plugin ClassLoader


Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/3e462d15
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/3e462d15
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/3e462d15

Branch: refs/heads/master
Commit: 3e462d15fe1b141e7ec90ed07cf03af8d418ef62
Parents: 433ab85
Author: rmani <rmani@hortonworks.com>
Authored: Mon Nov 2 16:33:00 2015 -0800
Committer: rmani <rmani@hortonworks.com>
Committed: Mon Nov 2 16:33:00 2015 -0800

----------------------------------------------------------------------
 .../classloader/RangerPluginClassLoader.java    | 34 +++++++++++++-------
 1 file changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/3e462d15/ranger-plugin-classloader/src/main/java/org/apache/ranger/plugin/classloader/RangerPluginClassLoader.java
----------------------------------------------------------------------
diff --git a/ranger-plugin-classloader/src/main/java/org/apache/ranger/plugin/classloader/RangerPluginClassLoader.java
b/ranger-plugin-classloader/src/main/java/org/apache/ranger/plugin/classloader/RangerPluginClassLoader.java
index eafcd27..23e16bf 100644
--- a/ranger-plugin-classloader/src/main/java/org/apache/ranger/plugin/classloader/RangerPluginClassLoader.java
+++ b/ranger-plugin-classloader/src/main/java/org/apache/ranger/plugin/classloader/RangerPluginClassLoader.java
@@ -22,11 +22,11 @@ package org.apache.ranger.plugin.classloader;
 import java.io.IOException;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedExceptionAction;
 import java.util.Enumeration;
 
-//import org.apache.commons.logging.Log;
-//import org.apache.commons.logging.LogFactory;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,24 +35,34 @@ public class RangerPluginClassLoader extends URLClassLoader {
 	
 	private static volatile RangerPluginClassLoader me 	             = null;
 	private static  MyClassLoader				componentClassLoader = null;
-	//private static ThreadLocal<MyClassLoader> componentClassLoader = new ThreadLocal<MyClassLoader>();
 		
 	public RangerPluginClassLoader(String pluginType, Class<?> pluginClass ) throws Exception
{
 		super(RangerPluginClassLoaderUtil.getInstance().getPluginFilesForServiceTypeAndPluginclass(pluginType,
pluginClass), null);
-		//componentClassLoader.set(new MyClassLoader(Thread.currentThread().getContextClassLoader()));
-		componentClassLoader = new MyClassLoader(Thread.currentThread().getContextClassLoader());
+		componentClassLoader = AccessController.doPrivileged(
+									new PrivilegedAction<MyClassLoader>() {
+										public MyClassLoader run() {
+												return  new MyClassLoader(Thread.currentThread().getContextClassLoader());
+										}
+									}
+								);
     }
 
-	public static RangerPluginClassLoader getInstance(String pluginType, Class<?> pluginClass
) throws Exception {
+	public static RangerPluginClassLoader getInstance(final String pluginType, final Class<?>
pluginClass ) throws Exception {
 		RangerPluginClassLoader ret = me;
 	    if ( ret == null) {
 		  synchronized(RangerPluginClassLoader.class) {
 		  ret = me;
 		  if ( ret == null){
-			  me = ret = new RangerPluginClassLoader(pluginType,pluginClass);
-			  }
-		  }
-		}
+			  me = ret = AccessController.doPrivileged(
+							new PrivilegedExceptionAction<RangerPluginClassLoader>(){
+								public RangerPluginClassLoader run() throws Exception {
+									return  new RangerPluginClassLoader(pluginType,pluginClass);
+							}
+						}
+				   );
+		      }
+		   }
+	   }
 	    return ret;
     }
 	
@@ -263,7 +273,7 @@ public class RangerPluginClassLoader extends URLClassLoader {
         }
     }
 
-    class MergeEnumeration implements Enumeration<URL> {
+   static class MergeEnumeration implements Enumeration<URL> {
 
         Enumeration<URL>  e1 = null;
         Enumeration<URL>  e2 = null;


Mime
View raw message