This is an automated email from the ASF dual-hosted git repository. pkarwasz pushed a commit to branch 2.x in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit 4c2435976df4877220aac965a8c6ae243140d4b6 Author: PanLongfei <[email protected]> AuthorDate: Sun Mar 24 12:35:07 2024 +0800 Fix issue 2380: consider ReusableParameterizedMessage's situation --- .../java/org/apache/logging/log4j/message/ParameterFormatter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterFormatter.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterFormatter.java index cdc0e1de69..ac96a1736f 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterFormatter.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterFormatter.java @@ -246,13 +246,13 @@ final class ParameterFormatter { // #2380: check if the count of placeholder is not equal to the count of arguments if (analysis.placeholderCount != argCount) { - final int realArgCount = args.length; - final int noThrowableArgCount = realArgCount - ((args[realArgCount - 1] instanceof Throwable) ? 1 : 0); + final int noThrowableArgCount = + argCount < 1 ? 0 : argCount - ((args[argCount - 1] instanceof Throwable) ? 1 : 0); if (analysis.placeholderCount != noThrowableArgCount) { STATUS_LOGGER.warn( "found {} argument placeholders, but provided {} for pattern `{}`", analysis.placeholderCount, - Math.min(realArgCount, argCount), + argCount, pattern); } }
