hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sj...@apache.org
Subject [50/50] [abbrv] hadoop git commit: HADOOP-13400. Update the ApplicationClassLoader implementation in line with latest Java ClassLoader implementation. Contributed by Vrushali C.
Date Tue, 18 Oct 2016 23:45:36 GMT
HADOOP-13400. Update the ApplicationClassLoader implementation in line with latest Java ClassLoader
implementation. Contributed by Vrushali C.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/f0e56e36
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/f0e56e36
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/f0e56e36

Branch: refs/heads/HADOOP-13070
Commit: f0e56e36498a3bb793b882c55efe118d355eeae3
Parents: c62ae71
Author: Sangjin Lee <sjlee@apache.org>
Authored: Tue Oct 18 16:44:06 2016 -0700
Committer: Sangjin Lee <sjlee@apache.org>
Committed: Tue Oct 18 16:44:06 2016 -0700

----------------------------------------------------------------------
 .../hadoop/util/ApplicationClassLoader.java     | 66 ++++++++++----------
 1 file changed, 33 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/f0e56e36/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ApplicationClassLoader.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ApplicationClassLoader.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ApplicationClassLoader.java
index 2f46e1f..9b89889 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ApplicationClassLoader.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/ApplicationClassLoader.java
@@ -158,49 +158,49 @@ public class ApplicationClassLoader extends URLClassLoader {
   }
 
   @Override
-  protected synchronized Class<?> loadClass(String name, boolean resolve)
+  protected Class<?> loadClass(String name, boolean resolve)
       throws ClassNotFoundException {
-    
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("Loading class: " + name);
-    }
+    synchronized (getClassLoadingLock(name)) {
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Loading class: " + name);
+      }
 
-    Class<?> c = findLoadedClass(name);
-    ClassNotFoundException ex = null;
+      Class<?> c = findLoadedClass(name);
+      ClassNotFoundException ex = null;
+
+      if (c == null && !isSystemClass(name, systemClasses)) {
+        // Try to load class from this classloader's URLs. Note that this is
+        // like the servlet spec, not the usual Java 2 behaviour where we ask
+        // the parent to attempt to load first.
+        try {
+          c = findClass(name);
+          if (LOG.isDebugEnabled() && c != null) {
+            LOG.debug("Loaded class: " + name + " ");
+          }
+        } catch (ClassNotFoundException e) {
+          if (LOG.isDebugEnabled()) {
+            LOG.debug(e);
+          }
+          ex = e;
+        }
+      }
 
-    if (c == null && !isSystemClass(name, systemClasses)) {
-      // Try to load class from this classloader's URLs. Note that this is like
-      // the servlet spec, not the usual Java 2 behaviour where we ask the
-      // parent to attempt to load first.
-      try {
-        c = findClass(name);
+      if (c == null) { // try parent
+        c = parent.loadClass(name);
         if (LOG.isDebugEnabled() && c != null) {
-          LOG.debug("Loaded class: " + name + " ");
+          LOG.debug("Loaded class from parent: " + name + " ");
         }
-      } catch (ClassNotFoundException e) {
-        if (LOG.isDebugEnabled()) {
-          LOG.debug(e);
-        }
-        ex = e;
       }
-    }
 
-    if (c == null) { // try parent
-      c = parent.loadClass(name);
-      if (LOG.isDebugEnabled() && c != null) {
-        LOG.debug("Loaded class from parent: " + name + " ");
+      if (c == null) {
+        throw ex != null ? ex : new ClassNotFoundException(name);
       }
-    }
 
-    if (c == null) {
-      throw ex != null ? ex : new ClassNotFoundException(name);
-    }
-
-    if (resolve) {
-      resolveClass(c);
+      if (resolve) {
+        resolveClass(c);
+      }
+      return c;
     }
-
-    return c;
   }
 
   /**


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message