Mal Graty created LOG4J2-1837:
---------------------------------
Summary: NdcPatternConverter isn't GC-free
Key: LOG4J2-1837
URL: https://issues.apache.org/jira/browse/LOG4J2-1837
Project: Log4j 2
Issue Type: Bug
Components: Pattern Converters
Affects Versions: 2.8.1, 2.8
Reporter: Mal Graty
Priority: Minor
The issue (LOG4J2-1715) sought to make the {{NdcPatternConverter}} GC-free, but
it looks as though that work doesn't get used. The interface
{{StringBuilderFormattable}} is never checked for when formatting in the
convertor, and as a result the builder is left to fend for itself, resorting
ultimately to {{String.valueOf}}.
I believe the code should end up looking something like this.
{code:title=NdcPatternConverter.java|borderStyle=solid}
public void format(final LogEvent event, final StringBuilder toAppendTo) {
ThreadContext.ContextStack stack = event.getContextStack();
if (is instanceof StringBuilderFormattable) {
((StringBuilderFormattable) stack).formatTo(toAppendTo);
} else {
toAppendTo.append(stack);
}
}
{code}
Happy to submit a patch if this makes sense or for someone else to. Still
getting my head around Log4j internals so confirmation of this would be helpful.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]