[java] InvalidLogMessageFormat: Add test case for #253

This commit is contained in:
Andreas Dangel
2024-04-05 15:45:29 +02:00
parent 84dc794a2d
commit 709396d8f3

View File

@ -1181,6 +1181,33 @@ public class Foo {
LOGGER.warn("Exception {}", IllegalStateException.class.getName(), exception());
}
}
]]></code>
</test-code>
<test-code>
<description>slf4j: [java] InvalidLogMessageFormat doesn't handle formats assembled via multi-stage concatenation #253</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Slf4JMessageFormatConcatenation {
private static final Logger LOG = LoggerFactory.getLogger(Slf4JMessageFormatConcatenation.class);
public void run() {
String message = "Field: {}";
// some code
String error = message + ", error: {}";
LOG.error(error, "fieldValue", "errorMessage"); // two placeholders, two args
// string concat with 7 params
int a, b, c, d, e, f, g;
LOGGER.warn("blah blah a={}, b={}, c={}, " +
"d={}, e={}, f={}, g={}",
a, b, c, d, e, f, g);
}
}
]]></code>
</test-code>
</test-data>