[
https://issues.apache.org/jira/browse/LOG4J2-2368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17494519#comment-17494519
]
ASF subversion and git services commented on LOG4J2-2368:
---------------------------------------------------------
Commit 5410ff51ba9556e7e8d200f255be0ff2d44a6fba in logging-log4j2's branch
refs/heads/release-2.x from Volkan Yazici
[ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=5410ff5 ]
LOG4J2-2368 Test JsonTemplateLayout's ThreadLocalRecycler against nested
logging.
> Outputs wrong message when used within overridden Throwable method
> ------------------------------------------------------------------
>
> Key: LOG4J2-2368
> URL: https://issues.apache.org/jira/browse/LOG4J2-2368
> Project: Log4j 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.8.1, 2.11.0
> Reporter: Taisuke Tashiro
> Assignee: Carter Kozak
> Priority: Major
> Fix For: 2.11.1, 3.0.0
>
>
> When a message A is logged with Throwable object and if message B is logged
> within the Throwable object's method, message A is lost and message B is
> logged instead.
> Following is a code example to recreate the issue:
> {{Logger loggerA = LogManager.getLogger("A");}}
> {{Logger loggerB = LogManager.getLogger("B");}}
> {{Throwable throwable =}}
> {{ new Throwable() {}}
> {{ public String getMessage() {}}
> {{ loggerB.debug("MESSAGE B");}}
> {{ return "message";}}
> {{ }}}
> {{ };}}
> {{loggerA.debug("MESSEGE A", throwable);}}
> "MESSAGE A" should be logged to loggerA but "MESSAGE B" is logged instead.
> Cause of this problem is reuse of StringBuilder instance within the execution
> thread in org.apache.logging.log4j.core.layout.AbstractStringLayout class.
> While processing loggerA, getMessage() is called by
> org.apache.logging.log4j.core.impl.ThrowableProxy to obtain throwable object
> information and the content of StringBuilder is changed by loggerB.
>
>
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)