cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r766860 - /cxf/trunk/common/common/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
Date Mon, 20 Apr 2009 20:40:39 GMT
Author: dkulp
Date: Mon Apr 20 20:40:39 2009
New Revision: 766860

URL: http://svn.apache.org/viewvc?rev=766860&view=rev
Log:
Check if classloader is null before using it.

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java?rev=766860&r1=766859&r2=766860&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
Mon Apr 20 20:40:39 2009
@@ -57,13 +57,16 @@
                 .getResource(resourceName.substring(1));
         }
 
+        ClassLoader cluClassloader = ClassLoaderUtils.class.getClassLoader();
+        if (cluClassloader == null) {
+            cluClassloader = ClassLoader.getSystemClassLoader();
+        }
         if (url == null) {
-            url = ClassLoaderUtils.class.getClassLoader().getResource(resourceName);
+            url = cluClassloader.getResource(resourceName);
         }
         if (url == null && resourceName.startsWith("/")) {
             //certain classloaders need it without the leading /
-            url = ClassLoaderUtils.class.getClassLoader()
-                .getResource(resourceName.substring(1));
+            url = cluClassloader.getResource(resourceName.substring(1));
         }
 
         if (url == null) {
@@ -124,9 +127,13 @@
             }
         }
 
+        ClassLoader cluClassloader = ClassLoaderUtils.class.getClassLoader();
+        if (cluClassloader == null) {
+            cluClassloader = ClassLoader.getSystemClassLoader();
+        }
         if (!urls.hasMoreElements()) {
             try {
-                urls = ClassLoaderUtils.class.getClassLoader().getResources(resourceName);
+                urls = cluClassloader.getResources(resourceName);
             } catch (IOException e) {
                 // ignore
             }
@@ -134,8 +141,7 @@
         if (!urls.hasMoreElements() && resourceName.startsWith("/")) {
             //certain classloaders need it without the leading /
             try {
-                urls = ClassLoaderUtils.class.getClassLoader()
-                    .getResources(resourceName.substring(1));
+                urls = cluClassloader.getResources(resourceName.substring(1));
             } catch (IOException e) {
                 // ignore
             }



Mime
View raw message