logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ruben (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-1542) java.lang.ArrayIndexOutOfBoundsException
Date Wed, 24 Aug 2016 10:19:21 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-1542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15434654#comment-15434654
] 

Ruben commented on LOG4J2-1542:
-------------------------------

I can confirm this bug, simply log something like:

logger.warn("", exception);

And then in a ListAppender try to receive the event, by calling getFormattedMessage in the
ParameterizedMessage it crashes due to this problem.

A workaround for me is something like:

			if(last.getMessage().getFormat() == null || last.getMessage().getFormat().isEmpty()) {
				//no message, lets return the exception message
				return last.getThrown().getMessage();
			} else {
				return last.getMessage().getFormattedMessage();
			}



> java.lang.ArrayIndexOutOfBoundsException
> ----------------------------------------
>
>                 Key: LOG4J2-1542
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1542
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: API
>    Affects Versions: 2.6.2
>         Environment: Array length logic causes throw java.lang.ArrayIndexOutOfBoundsException
>            Reporter: Rogério Lecarião Leite
>            Priority: Critical
>              Labels: easyfix
>   Original Estimate: 1h
>  Remaining Estimate: 1h
>
> This error is reproducible when method fomarTo of the class ParameterizedMessage is invoked.
> This root cause is the method init of same class where is invoked, in the this.indices
is initializaded with messagePattern.length() >> 1 run to equals zero because that messagePattern.length()
is 1 (string with one character).
> I used File Appender in my XML config and I wrote my code with logger.trace("a").
> My PatternLayout used is pattern="%m" (simplest).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message