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:
@@ -380,6 +380,14 @@ public abstract class LogFactory {
|
||||
|
||||
// --------------------------------------------------------- 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>
|
||||
* instance, using the following ordered lookup procedure to determine
|
||||
@@ -499,7 +507,7 @@ public abstract class LogFactory {
|
||||
logDiagnostic(
|
||||
"[LOOKUP] A security exception occurred while trying to create an"
|
||||
+ " instance of the custom factory class"
|
||||
+ ": [" + e.getMessage().trim()
|
||||
+ ": [" + trim(e.getMessage())
|
||||
+ "]. Trying alternative implementations...");
|
||||
}
|
||||
; // ignore
|
||||
@@ -513,7 +521,7 @@ public abstract class LogFactory {
|
||||
logDiagnostic(
|
||||
"[LOOKUP] An exception occurred while trying to create an"
|
||||
+ " instance of the custom factory class"
|
||||
+ ": [" + e.getMessage().trim()
|
||||
+ ": [" + trim(e.getMessage())
|
||||
+ "] as specified by a system property.");
|
||||
}
|
||||
throw e;
|
||||
@@ -576,7 +584,7 @@ public abstract class LogFactory {
|
||||
logDiagnostic(
|
||||
"[LOOKUP] A security exception occurred while trying to create an"
|
||||
+ " instance of the custom factory class"
|
||||
+ ": [" + ex.getMessage().trim()
|
||||
+ ": [" + trim(ex.getMessage())
|
||||
+ "]. Trying alternative implementations...");
|
||||
}
|
||||
; // ignore
|
||||
|
||||
Reference in New Issue
Block a user