mirror of https://github.com/qos-ch/slf4j
fixing SLF4J-337
This commit is contained in:
parent
715615cd36
commit
c41df923f2
|
|
@ -261,7 +261,13 @@ public class SLF4JBridgeHandler extends Handler {
|
|||
// avoid formatting when there are no or 0 parameters. see also
|
||||
// http://jira.qos.ch/browse/SLF4J-203
|
||||
if (params != null && params.length > 0) {
|
||||
message = MessageFormat.format(message, params);
|
||||
try {
|
||||
message = MessageFormat.format(message, params);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// default to the same behavior as in java.util.logging.Formatter.formatMessage(LogRecord)
|
||||
// see also http://jira.qos.ch/browse/SLF4J-337
|
||||
return message;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -178,6 +178,19 @@ public class SLF4JBridgeHandlerTest {
|
|||
assertEquals(msg, le.getMessage());
|
||||
}
|
||||
|
||||
// See http://jira.qos.ch/browse/SLF4J-337
|
||||
|
||||
@Test
|
||||
public void illFormattedInputShouldBeReturnedAsIs() {
|
||||
SLF4JBridgeHandler.install();
|
||||
String msg = "foo {18=bad} {0}";
|
||||
|
||||
julLogger.log(Level.INFO, msg, "ignored parameter due to IllegalArgumentException");
|
||||
assertEquals(1, listAppender.list.size());
|
||||
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
|
||||
assertEquals(msg, le.getMessage());
|
||||
}
|
||||
|
||||
void assertLevel(int index, org.apache.log4j.Level expectedLevel) {
|
||||
LoggingEvent le = (LoggingEvent) listAppender.list.get(index);
|
||||
assertEquals(expectedLevel, le.getLevel());
|
||||
|
|
|
|||
|
|
@ -31,12 +31,19 @@
|
|||
|
||||
<h3>, 2015 - Release of SLF4J 1.7.13</h3>
|
||||
|
||||
<p>Fixed issue with BasicMDCAdapter leaking MDC information to
|
||||
non-child threads. This problem was reported by Lukasz Cwik in <a
|
||||
<p>Fixed issue with <code>BasicMDCAdapter</code> leaking MDC
|
||||
information to non-child threads. This problem was reported by
|
||||
Lukasz Cwik in <a
|
||||
href="http://jira.qos.ch/browse/SLF4J-316">SLF4J-316</a> who also
|
||||
provided the relavant pull request.
|
||||
</p>
|
||||
|
||||
<p>More robust handling of ill-formatted input strings by
|
||||
SLF4JBridgeHandler. This issue was reported in <a
|
||||
href="http://jira.qos.ch/browse/SLF4J-337">SLF4J-337</a> by Rodolfo
|
||||
Udo Labsch.
|
||||
</p>
|
||||
|
||||
<p>House cleaning of our project's Maven <em>pom.xml</em> files, an
|
||||
initiative undertaken by Jeremy Landis.
|
||||
</p>
|
||||
|
|
|
|||
Loading…
Reference in New Issue