1
0

Fix possible null-pointer exception when generating diagnostic messages. JIRA issue LOGGING-115. Thanks to Frantisek Jandos for the bugreport.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/logging/trunk@593798 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Simon Kitching
2007-11-10 17:40:43 +00:00
parent 4e8ae13c0c
commit 8367500593

View File

@@ -380,6 +380,14 @@ public abstract class LogFactory {
// --------------------------------------------------------- Static Methods // --------------------------------------------------------- Static Methods
/** Utility method to safely trim a string. */
private static String trim(String src) {
if (src == null) {
return null;
}
return src.trim();
}
/** /**
* <p>Construct (if necessary) and return a <code>LogFactory</code> * <p>Construct (if necessary) and return a <code>LogFactory</code>
* instance, using the following ordered lookup procedure to determine * instance, using the following ordered lookup procedure to determine
@@ -499,7 +507,7 @@ public abstract class LogFactory {
logDiagnostic( logDiagnostic(
"[LOOKUP] A security exception occurred while trying to create an" "[LOOKUP] A security exception occurred while trying to create an"
+ " instance of the custom factory class" + " instance of the custom factory class"
+ ": [" + e.getMessage().trim() + ": [" + trim(e.getMessage())
+ "]. Trying alternative implementations..."); + "]. Trying alternative implementations...");
} }
; // ignore ; // ignore
@@ -513,7 +521,7 @@ public abstract class LogFactory {
logDiagnostic( logDiagnostic(
"[LOOKUP] An exception occurred while trying to create an" "[LOOKUP] An exception occurred while trying to create an"
+ " instance of the custom factory class" + " instance of the custom factory class"
+ ": [" + e.getMessage().trim() + ": [" + trim(e.getMessage())
+ "] as specified by a system property."); + "] as specified by a system property.");
} }
throw e; throw e;
@@ -576,7 +584,7 @@ public abstract class LogFactory {
logDiagnostic( logDiagnostic(
"[LOOKUP] A security exception occurred while trying to create an" "[LOOKUP] A security exception occurred while trying to create an"
+ " instance of the custom factory class" + " instance of the custom factory class"
+ ": [" + ex.getMessage().trim() + ": [" + trim(ex.getMessage())
+ "]. Trying alternative implementations..."); + "]. Trying alternative implementations...");
} }
; // ignore ; // ignore