Author: dan.j.allen
Date: 2009-05-02 02:04:03 -0400 (Sat, 02 May 2009)
New Revision: 2642
Modified:
ri/trunk/logging/src/main/java/org/jboss/webbeans/log/LogImpl.java
ri/trunk/logging/src/test/java/org/jboss/webbeans/test/log/LoggingTest.java
Log:
don't barf on a null value, complete with test
Modified: ri/trunk/logging/src/main/java/org/jboss/webbeans/log/LogImpl.java
===================================================================
--- ri/trunk/logging/src/main/java/org/jboss/webbeans/log/LogImpl.java 2009-05-01 19:50:09
UTC (rev 2641)
+++ ri/trunk/logging/src/main/java/org/jboss/webbeans/log/LogImpl.java 2009-05-02 06:04:03
UTC (rev 2642)
@@ -176,7 +176,7 @@
{
for (int i = 0; i < params.length; i++)
{
- if (params[i].getClass().isArray())
+ if (params[i] != null && params[i].getClass().isArray())
{
params[i] = Arrays.asList((Object[]) params[i]);
}
Modified: ri/trunk/logging/src/test/java/org/jboss/webbeans/test/log/LoggingTest.java
===================================================================
--- ri/trunk/logging/src/test/java/org/jboss/webbeans/test/log/LoggingTest.java 2009-05-01
19:50:09 UTC (rev 2641)
+++ ri/trunk/logging/src/test/java/org/jboss/webbeans/test/log/LoggingTest.java 2009-05-02
06:04:03 UTC (rev 2642)
@@ -56,6 +56,18 @@
assert TestAppender.getLastEvent() != null : "There was no last event in
Log4j";
assert TestAppender.getLastEvent().getRenderedMessage().equals("Message with 3
parameters starting with param1 and including param2");
}
+
+ @Test
+ public void testLogMessageFormattingWithNullValue()
+ {
+ Log log = Logging.getLog(LoggingTest.class);
+ assert log != null : "No Log object returned";
+
+ String value = null;
+ log.info("Verify we do not barf on a {0} value", value);
+ assert TestAppender.getLastEvent() != null : "There was no last event in
Log4j";
+ assert TestAppender.getLastEvent().getRenderedMessage().equals("Verify we do
not barf on a null value");
+ }
@Test
public void testArrayConversion()