commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1362964 - /commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/SimpleLog.java
Date Wed, 18 Jul 2012 14:30:31 GMT
Author: sebb
Date: Wed Jul 18 14:30:31 2012
New Revision: 1362964

URL: http://svn.apache.org/viewvc?rev=1362964&view=rev
Log:
Redundant null check

Modified:
    commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/SimpleLog.java

Modified: commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/SimpleLog.java
URL: http://svn.apache.org/viewvc/commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/SimpleLog.java?rev=1362964&r1=1362963&r2=1362964&view=diff
==============================================================================
--- commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/SimpleLog.java (original)
+++ commons/proper/logging/trunk/src/java/org/apache/commons/logging/impl/SimpleLog.java Wed
Jul 18 14:30:31 2012
@@ -650,48 +650,46 @@ public class SimpleLog implements Log, S
     {
         ClassLoader classLoader = null;
 
-        if (classLoader == null) {
+        try {
+            // Are we running on a JDK 1.2 or later system?
+            Method method = Thread.class.getMethod("getContextClassLoader",
+                    (Class[]) null);
+
+            // Get the thread context class loader (if there is one)
             try {
-                // Are we running on a JDK 1.2 or later system?
-                Method method = Thread.class.getMethod("getContextClassLoader",
+                classLoader = (ClassLoader)method.invoke(Thread.currentThread(), 
                         (Class[]) null);
-
-                // Get the thread context class loader (if there is one)
-                try {
-                    classLoader = (ClassLoader)method.invoke(Thread.currentThread(), 
-                            (Class[]) null);
-                } catch (IllegalAccessException e) {
+            } catch (IllegalAccessException e) {
+                // ignore
+            } catch (InvocationTargetException e) {
+                /**
+                 * InvocationTargetException is thrown by 'invoke' when
+                 * the method being invoked (getContextClassLoader) throws
+                 * an exception.
+                 *
+                 * getContextClassLoader() throws SecurityException when
+                 * the context class loader isn't an ancestor of the
+                 * calling class's class loader, or if security
+                 * permissions are restricted.
+                 *
+                 * In the first case (not related), we want to ignore and
+                 * keep going.  We cannot help but also ignore the second
+                 * with the logic below, but other calls elsewhere (to
+                 * obtain a class loader) will trigger this exception where
+                 * we can make a distinction.
+                 */
+                if (e.getTargetException() instanceof SecurityException) {
                     // ignore
-                } catch (InvocationTargetException e) {
-                    /**
-                     * InvocationTargetException is thrown by 'invoke' when
-                     * the method being invoked (getContextClassLoader) throws
-                     * an exception.
-                     *
-                     * getContextClassLoader() throws SecurityException when
-                     * the context class loader isn't an ancestor of the
-                     * calling class's class loader, or if security
-                     * permissions are restricted.
-                     *
-                     * In the first case (not related), we want to ignore and
-                     * keep going.  We cannot help but also ignore the second
-                     * with the logic below, but other calls elsewhere (to
-                     * obtain a class loader) will trigger this exception where
-                     * we can make a distinction.
-                     */
-                    if (e.getTargetException() instanceof SecurityException) {
-                        // ignore
-                    } else {
-                        // Capture 'e.getTargetException()' exception for details
-                        // alternate: log 'e.getTargetException()', and pass back 'e'.
-                        throw new LogConfigurationException
-                            ("Unexpected InvocationTargetException", e.getTargetException());
-                    }
+                } else {
+                    // Capture 'e.getTargetException()' exception for details
+                    // alternate: log 'e.getTargetException()', and pass back 'e'.
+                    throw new LogConfigurationException
+                        ("Unexpected InvocationTargetException", e.getTargetException());
                 }
-            } catch (NoSuchMethodException e) {
-                // Assume we are running on JDK 1.1
-                // ignore
             }
+        } catch (NoSuchMethodException e) {
+            // Assume we are running on JDK 1.1
+            // ignore
         }
 
         if (classLoader == null) {



Mime
View raw message