Resolve NullPointerExceptions
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@138893 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java,v 1.10 2002/06/11 22:35:33 rsitze Exp $
|
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//logging/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java,v 1.11 2002/06/11 22:47:21 rsitze Exp $
|
||||||
* $Revision: 1.10 $
|
* $Revision: 1.11 $
|
||||||
* $Date: 2002/06/11 22:35:33 $
|
* $Date: 2002/06/11 22:47:21 $
|
||||||
*
|
*
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*
|
*
|
||||||
@@ -104,7 +104,7 @@ import org.apache.commons.logging.LogSource;
|
|||||||
*
|
*
|
||||||
* @author Rod Waldhoff
|
* @author Rod Waldhoff
|
||||||
* @author Craig R. McClanahan
|
* @author Craig R. McClanahan
|
||||||
* @version $Revision: 1.10 $ $Date: 2002/06/11 22:35:33 $
|
* @version $Revision: 1.11 $ $Date: 2002/06/11 22:47:21 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class LogFactoryImpl extends LogFactory {
|
public class LogFactoryImpl extends LogFactory {
|
||||||
@@ -403,6 +403,10 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
Class logClass = null;
|
Class logClass = null;
|
||||||
try {
|
try {
|
||||||
logClass = loadClass(logClassName);
|
logClass = loadClass(logClassName);
|
||||||
|
if (logClass == null) {
|
||||||
|
throw new LogConfigurationException
|
||||||
|
("No suitable Log implementation for " + logClassName);
|
||||||
|
}
|
||||||
if (!Log.class.isAssignableFrom(logClass)) {
|
if (!Log.class.isAssignableFrom(logClass)) {
|
||||||
throw new LogConfigurationException
|
throw new LogConfigurationException
|
||||||
("Class " + logClassName + " does not implement Log");
|
("Class " + logClassName + " does not implement Log");
|
||||||
@@ -438,21 +442,29 @@ public class LogFactoryImpl extends LogFactory {
|
|||||||
throws ClassNotFoundException
|
throws ClassNotFoundException
|
||||||
{
|
{
|
||||||
ClassLoader threadCL = getContextClassLoader();
|
ClassLoader threadCL = getContextClassLoader();
|
||||||
try {
|
|
||||||
return threadCL.loadClass(name);
|
if (threadCL != null) {
|
||||||
} catch( ClassNotFoundException ex ) {
|
try {
|
||||||
return Class.forName( name );
|
return threadCL.loadClass(name);
|
||||||
|
} catch( ClassNotFoundException ex ) {
|
||||||
|
return Class.forName( name );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void guessConfig() {
|
protected void guessConfig() {
|
||||||
if( isLog4JAvailable() ) {
|
if( isLog4JAvailable() ) {
|
||||||
|
proxyFactory = null;
|
||||||
try {
|
try {
|
||||||
Class proxyClass=
|
Class proxyClass=
|
||||||
loadClass( "org.apache.commons.logging.impl.Log4jFactory" );
|
loadClass( "org.apache.commons.logging.impl.Log4jFactory" );
|
||||||
proxyFactory=(LogFactory)proxyClass.newInstance();
|
if (proxyClass != null) {
|
||||||
|
proxyFactory = (LogFactory)proxyClass.newInstance();
|
||||||
|
}
|
||||||
} catch( Throwable t ) {
|
} catch( Throwable t ) {
|
||||||
proxyFactory=null;
|
; // ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// other logger specific initialization
|
// other logger specific initialization
|
||||||
|
|||||||
Reference in New Issue
Block a user