Joern Huxhorn created SLF4J-397: ----------------------------------- Summary: Bridge can still call underlying logging system with a null message. Key: SLF4J-397 URL: https://jira.qos.ch/browse/SLF4J-397 Project: SLF4J Issue Type: Bug Components: jul-to-slf4j Affects Versions: 1.7.24 Environment: any Reporter: Joern Huxhorn Assignee: SLF4J developers list
I just found a bug while preparing SLF4J-396. {code:java} private String getMessageI18N(LogRecord record) { String message = record.getMessage(); if (message == null) { return null; } // [..] } {code} should be changed to {code:java} private String getMessageI18N(LogRecord record) { String message = record.getMessage(); // can be null! // this is a check to avoid calling the underlying logging system // with a null message. While it is legitimate to invoke j.u.l. with // a null message, other logging frameworks do not support this. // see also http://jira.qos.ch/browse/SLF4J-99 if (message == null) { return ""; } // [..] } {code} and {code:java} public void publish(LogRecord record) { // Silently ignore null records. if (record == null) { return; } Logger slf4jLogger = getSLF4JLogger(record); String message = record.getMessage(); // can be null! // this is a check to avoid calling the underlying logging system // with a null message. While it is legitimate to invoke j.u.l. with // a null message, other logging frameworks do not support this. // see also http://jira.qos.ch/browse/SLF4J-99 if (message == null) { message = ""; } if (slf4jLogger instanceof LocationAwareLogger) { callLocationAwareLogger((LocationAwareLogger) slf4jLogger, record); } else { callPlainSLF4JLogger(slf4jLogger, record); } } {code} should be changed to {code:java} public void publish(LogRecord record) { // Silently ignore null records. if (record == null) { return; } Logger slf4jLogger = getSLF4JLogger(record); if (slf4jLogger instanceof LocationAwareLogger) { callLocationAwareLogger((LocationAwareLogger) slf4jLogger, record); } else { callPlainSLF4JLogger(slf4jLogger, record); } } {code} The local {{message}} variable was assigned but never used. I suspect some refactoring sneakily reintroduced the problematic case where the underlying logging system is called with a {{null}} message. {{getMessageI18N}} is called by both {{callLocationAwareLogger}} and {{callPlainSLF4JLogger}} so this fix should be fine. -- This message was sent by Atlassian JIRA (v7.3.1#73012) _______________________________________________ slf4j-dev mailing list slf4j-dev@qos.ch http://mailman.qos.ch/mailman/listinfo/slf4j-dev