Menu

#24 Incorrect warning "Throwables cannot be used in combination with formatted log messages"

v1.0.11
open
None
5
2014-11-27
2014-11-24
Yuval
No

The following leads to a warning in intellij, "Throwables cannot be used in combination with formatted log messages":

public static void main(String[] args) {
  String a = null;
  try {
    a.isEmpty();
  } catch (NullPointerException e) {
    log.warn("variable is null: {}", "a", e);
  }
}

But this actually works fine. The log message comes through with the message "variable is null: a" followed by the stack trace.

This is using slf4j-api 1.7.7 with slf4j-log4j12 1.7.7 and log4j 1.2.17.

Discussion

  • Yuval

    Yuval - 2014-11-24

    Oh, I just realized I can turn this off via "verify throwable in formatted message" options in inspections. Sorry! I can't find the close button on the bug, maybe I don't have permissions for it?

     
  • Jürgen Kellerer

    Hi Yuval, thanks for the report, I'll keep it open as I have to review this project anyway once I find the time for it.
    Such changes in behavior of updated versions of log frameworks should be handled somehow. (At least there should be presets for newer versions of slf4j that already contain the correct config)

     
  • Jürgen Kellerer

    • assigned_to: Jürgen Kellerer
     

Log in to post a comment.