fix bug 212

This commit is contained in:
Ceki Gulcu 2013-03-13 11:44:32 +01:00
parent 8d30219371
commit eaf1d80e60
3 changed files with 11 additions and 2 deletions

View File

@ -262,6 +262,8 @@ public class SLF4JBridgeHandler extends Handler {
}
}
Object[] params = record.getParameters();
// avoid formatting when there are no or 0 parameters. see also
// http://bugzilla.slf4j.org/show_bug.cgi?id=212
if (params != null && params.length > 0) {
message = MessageFormat.format(message, params);
}

View File

@ -170,7 +170,7 @@ public class SLF4JBridgeHandlerTest extends TestCase {
public void testLogWithPlaceholderNoParameters() {
SLF4JBridgeHandler.install();
String msg = "msg {}";
String msg = "msg {non-number-string}";
julLogger.logp(Level.INFO, "SLF4JBridgeHandlerTest", "testLogWithPlaceholderNoParameters", msg, new Object[0]);
assertEquals(1, listAppender.list.size());

9
slf4j-site/src/site/pages/news.html Normal file → Executable file
View File

@ -29,8 +29,15 @@
<hr noshade="noshade" size="1"/>
<h3> November, 2012 - Release of SLF4J 1.7.3</h3>
<h3>13th of March, 2013 - Release of SLF4J 1.7.3</h3>
<p>The jul-to-slf4j bridge now correctly handles cases where the
message string contains {}-placeholders but has no or zero
parameters. This fixes <a
href="http://bugzilla.slf4j.org/show_bug.cgi?id=212">bug
#212</a>. The relevant patch was provided by Matthew Preston in a
git pull request.</p>
<p>Added missing methods and classes in log4j-over-slf4j module for
Velocity compatibility. This isssue was reported in <a
href="http://bugzilla.slf4j.org/show_bug.cgi?id=280">bug 280</a> by