You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2019/05/29 14:55:41 UTC

[cxf] branch master updated: Trivial change not to create the classloader twice

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new a079c5e  Trivial change not to create the classloader twice
a079c5e is described below

commit a079c5ee91dcfa167243658f110e99c9d61178f3
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Wed May 29 15:55:10 2019 +0100

    Trivial change not to create the classloader twice
---
 .../java/org/apache/cxf/common/classloader/ClassLoaderUtils.java  | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

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 18784c3..5f446f1 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
@@ -109,10 +109,11 @@ public final class ClassLoaderUtils {
      * @param callingClass The Class object of the calling object
      */
     public static URL getResource(String resourceName, Class<?> callingClass) {
-        URL url = getContextClassLoader().getResource(resourceName);
+        ClassLoader contextClassLoader = getContextClassLoader();
+        URL url = contextClassLoader.getResource(resourceName);
         if (url == null && resourceName.startsWith("/")) {
             //certain classloaders need it without the leading /
-            url = getContextClassLoader().getResource(resourceName.substring(1));
+            url = contextClassLoader.getResource(resourceName.substring(1));
         }
 
         ClassLoader cluClassloader = ClassLoaderUtils.class.getClassLoader();
@@ -277,6 +278,7 @@ public final class ClassLoaderUtils {
         }
         return loadClass2(className, callingClass);
     }
+
     public static <T> Class<? extends T> loadClass(String className, Class<?> callingClass, Class<T> type)
         throws ClassNotFoundException {
         try {
@@ -331,7 +333,7 @@ public final class ClassLoaderUtils {
                     return loader != null ? loader : ClassLoader.getSystemClassLoader();
                 }
             });
-        } 
+        }
         ClassLoader loader = Thread.currentThread().getContextClassLoader();
         return loader != null ? loader : ClassLoader.getSystemClassLoader();
     }