cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [8/8] cxf git commit: Fix merge
Date Mon, 26 Jun 2017 21:08:33 GMT
Fix merge


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

Branch: refs/heads/3.0.x-fixes
Commit: 60cb4240c3004874bc535a7c3a5e14f71c9fcc2c
Parents: a1306fc
Author: Daniel Kulp <dkulp@apache.org>
Authored: Mon Jun 26 15:48:33 2017 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Mon Jun 26 15:48:33 2017 -0400

----------------------------------------------------------------------
 .../common/classloader/ClassLoaderUtils.java    | 46 +++++++++++---------
 1 file changed, 25 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/60cb4240/core/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java b/core/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
index 1e61070..7170c19 100644
--- a/core/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
@@ -36,16 +36,16 @@ import java.util.List;
  * verify any change on 6 different application servers.
  */
 public final class ClassLoaderUtils {
-    
+
     private ClassLoaderUtils() {
     }
-    
+
     public static class ClassLoaderHolder {
         ClassLoader loader;
         ClassLoaderHolder(ClassLoader c) {
             loader = c;
         }
-        
+
         public void reset() {
             ClassLoaderUtils.setThreadContextClassloader(loader);
         }
@@ -59,7 +59,7 @@ public final class ClassLoaderUtils {
             }
         });
     }
-    
+
     public static ClassLoader getURLClassLoader(
         final URL[] urls, final ClassLoader parent
     ) {
@@ -75,7 +75,7 @@ public final class ClassLoaderUtils {
     ) {
         return getURLClassLoader(urlList.toArray(new URL[urlList.size()]), parent);
     }
-    
+
     /**
      * Load a given resource. <p/> This method will try to load the resource
      * using the following methods (in order):
@@ -84,7 +84,7 @@ public final class ClassLoaderUtils {
      * <li>From ClassLoaderUtil.class.getClassLoader()
      * <li>callingClass.getClassLoader()
      * </ul>
-     * 
+     *
      * @param resourceName The name of the resource to load
      * @param callingClass The Class object of the calling object
      */
@@ -118,14 +118,14 @@ public final class ClassLoaderUtils {
         if (url == null) {
             url = callingClass.getResource(resourceName);
         }
-        
+
         if ((url == null) && (resourceName != null) && (resourceName.charAt(0)
!= '/')) {
             return getResource('/' + resourceName, callingClass);
         }
 
         return url;
     }
-    
+
     /**
      * Load a given resources. <p/> This method will try to load the resources
      * using the following methods (in order):
@@ -134,7 +134,7 @@ public final class ClassLoaderUtils {
      * <li>From ClassLoaderUtil.class.getClassLoader()
      * <li>callingClass.getClassLoader()
      * </ul>
-     * 
+     *
      * @param resourceName The name of the resource to load
      * @param callingClass The Class object of the calling object
      */
@@ -147,7 +147,7 @@ public final class ClassLoaderUtils {
             public URL nextElement() {
                 return null;
             }
-            
+
         };
         try {
             urls = getContextClassLoader().getResources(resourceName);
@@ -205,7 +205,7 @@ public final class ClassLoaderUtils {
             ret.add(urls.nextElement());
         }
 
-        
+
         if (ret.isEmpty() && (resourceName != null) && (resourceName.charAt(0)
!= '/')) {
             return getResources('/' + resourceName, callingClass);
         }
@@ -216,7 +216,7 @@ public final class ClassLoaderUtils {
     /**
      * This is a convenience method to load a resource as a stream. <p/> The
      * algorithm used to find the resource is given in getResource()
-     * 
+     *
      * @param resourceName The name of the resource to load
      * @param callingClass The Class object of the calling object
      */
@@ -239,7 +239,7 @@ public final class ClassLoaderUtils {
      * <li>From ClassLoaderUtil.class.getClassLoader()
      * <li>From the callingClass.getClassLoader()
      * </ul>
-     * 
+     *
      * @param className The name of the class to load
      * @param callingClass The Class object of the calling object
      * @throws ClassNotFoundException If the class cannot be found anywhere.
@@ -247,11 +247,11 @@ public final class ClassLoaderUtils {
     public static Class<?> loadClass(String className, Class<?> callingClass)
         throws ClassNotFoundException {
         try {
-            ClassLoader cl = Thread.currentThread().getContextClassLoader();
+            ClassLoader cl = getContextClassLoader();
 
             if (cl != null) {
                 return cl.loadClass(className);
-            }            
+            }
         } catch (ClassNotFoundException e) {
             //ignore
         }
@@ -260,11 +260,11 @@ public final class ClassLoaderUtils {
     public static <T> Class<? extends T> loadClass(String className, Class<?>
callingClass, Class<T> type)
         throws ClassNotFoundException {
         try {
-            ClassLoader cl = Thread.currentThread().getContextClassLoader();
+            ClassLoader cl = getContextClassLoader();
 
             if (cl != null) {
                 return cl.loadClass(className).asSubclass(type);
-            }            
+            }
         } catch (ClassNotFoundException e) {
             //ignore
         }
@@ -276,12 +276,16 @@ public final class ClassLoaderUtils {
             return Class.forName(className);
         } catch (ClassNotFoundException ex) {
             try {
-                if (ClassLoaderUtils.class.getClassLoader() != null) {
-                    return ClassLoaderUtils.class.getClassLoader().loadClass(className);
+                final ClassLoader loader = getClassLoader(ClassLoaderUtils.class);
+                if (loader != null) {
+                    return loader.loadClass(className);
                 }
             } catch (ClassNotFoundException exc) {
-                if (callingClass != null && callingClass.getClassLoader() != null)
{
-                    return callingClass.getClassLoader().loadClass(className);
+                if (callingClass != null) {
+                    final ClassLoader callingClassLoader = getClassLoader(callingClass);
+                    if (callingClassLoader != null) {
+                        return callingClassLoader.loadClass(className);
+                    }
                 }
             }
             throw ex;


Mime
View raw message