[
https://issues.apache.org/jira/browse/LOG4J2-811?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14119419#comment-14119419
]
Remko Popma edited comment on LOG4J2-811 at 9/3/14 11:54 AM:
-------------------------------------------------------------
Assigned to Gary since he is working on this - I hope that is okay.
I agree that not throwing an exception is better.
Gary, your fix covers the empty array case. Should we also cover cases where
the user does
{{logger.error("Hello World {} in {} " , new String[] {"only one param"\});}} -
so the number of provided is less than required by the pattern?
EDIT: on closer inspection this is not actually a problem; PatternMessage
already handles this case.
was (Author: [email protected]):
Assigned to Gary since he is working on this - I hope that is okay.
I agree that not throwing an exception is better.
Gary, your fix covers the empty array case. Should we also cover cases where
the user does
{{logger.error("Hello World {} in {} " , new String[] {"only one param"\});}} -
so the number of provided is less than required by the pattern?
> SimpleLogger throws ArrayIndexOutOfBoundsException for an empty array
> ---------------------------------------------------------------------
>
> Key: LOG4J2-811
> URL: https://issues.apache.org/jira/browse/LOG4J2-811
> Project: Log4j 2
> Issue Type: Bug
> Components: API
> Affects Versions: 2.0.1
> Reporter: Yogesh Rao
> Assignee: Gary Gregory
> Labels: patch
> Fix For: 2.1
>
>
> There seems to be an issue with SimpleLogger implementation provided by
> log4j2. The issue seems to be in the new improved API supporting placeholders
> and var args when called with an Object Array of size 0.
> for e.g logger.error("Hello World {} in {} " , new Object[0]);
> A statement above results in an error as shown below
> ERROR StatusLogger Unable to locate a logging implementation, using
> SimpleLogger
> Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
> at
> org.apache.logging.log4j.simple.SimpleLogger.logMessage(SimpleLogger.java:157)
> at
> org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:1347)
> at
> org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:1312)
> at
> org.apache.logging.log4j.spi.AbstractLogger.error(AbstractLogger.java:539)
> at TestError.main(TestError.java:21)
> Solution to place a check in SimpleLogger for checking the size of the array
> .
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]