1
0

Redundant null check

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/logging/trunk@1362964 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sebastian Bazley
2012-07-18 14:30:31 +00:00
parent cabf9b0bc0
commit 821ac94474

View File

@@ -650,48 +650,46 @@ public class SimpleLog implements Log, Serializable {
{ {
ClassLoader classLoader = null; ClassLoader classLoader = null;
if (classLoader == null) { try {
try { // Are we running on a JDK 1.2 or later system?
// Are we running on a JDK 1.2 or later system? Method method = Thread.class.getMethod("getContextClassLoader",
Method method = Thread.class.getMethod("getContextClassLoader", (Class[]) null);
(Class[]) null);
// Get the thread context class loader (if there is one) // Get the thread context class loader (if there is one)
try { try {
classLoader = (ClassLoader)method.invoke(Thread.currentThread(), classLoader = (ClassLoader)method.invoke(Thread.currentThread(),
(Class[]) null); (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
} 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 // 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());
}
} }
} catch (NoSuchMethodException e) {
// Assume we are running on JDK 1.1
// ignore
} }
if (classLoader == null) { if (classLoader == null) {