Menu

#1416 Logging checks should not fire for statis string concatenation

New Tickets
open
nobody
None
PMD
3-Major
Bug
Logging
2015-12-04
2015-09-28
john
No

Currently the guard logging checks fire for string literal concatenation, but most compilers these days are smart enough to pre concatenate those ahead of time:
i.e.
"log this" + " and " + "this" will compile to "log this and this" and will not trigger a runtime hit on string concatenation.

Many compilers will even pre-optimize something like this:

public class StringCatConstant {
private static final String MY_CONST = "My String Constant";

public void main(String ...args) {
    log.debug("My String Literal concatenated with " + MY_CONST);
}

The guard logging should be modified to only flag concatenation with variables.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB