[slf4j-user] Small bug in SLF4JBridgeHandler ?

Maarten Bosteels mbosteels.dns at gmail.com
Thu Jan 10 10:22:01 CET 2013


Hello,

https://github.com/qos-ch/slf4j/blob/master/jul-to-slf4j/src/main/java/org/slf4j/bridge/SLF4JBridgeHandler.java#L283


     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://bugzilla.slf4j.org/show_bug.cgi?id=108
    if (message == null) {
      message = "";
    }
    if (slf4jLogger instanceof LocationAwareLogger) {
      callLocationAwareLogger((LocationAwareLogger) slf4jLogger, record);
    } else {
      callPlainSLF4JLogger(slf4jLogger, record);
    }
  }


I don't understand the point of changing the local variable message to
the empty string since that local variable is not used afterwards.
Shouldn't this be like this :

    if (message == null) {
      record.setMessage("");
    }

Should a file a bug ?

Best regards
Maarten
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/slf4j-user/attachments/20130110/65c56f18/attachment.html>


More information about the slf4j-user mailing list