Author: skitching
Date: Sat Nov 10 09:40:43 2007
New Revision: 593798
URL: http://svn.apache.org/viewvc?rev=593798&view=rev
Log:
Fix possible null-pointer exception when generating diagnostic messages. JIRA
issue LOGGING-115. Thanks to Frantisek Jandos for the bugreport.
Modified:
commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java
Modified:
commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java
URL:
http://svn.apache.org/viewvc/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java?rev=593798&r1=593797&r2=593798&view=diff
==============================================================================
---
commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java
(original)
+++
commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java
Sat Nov 10 09:40:43 2007
@@ -380,6 +380,14 @@
// --------------------------------------------------------- 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 @@
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 @@
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 @@
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