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

Stefan Hammelbeck commented on LOG4J2-1688:
-------------------------------------------

The actual reset seems to happen in {{ReusableLogEventFactory}}:
{code}
...
    @Override
    public LogEvent createEvent(final String loggerName, final Marker marker,
                                final String fqcn, final Level level, final 
Message message,
                                final List<Property> properties, final 
Throwable t) {
        MutableLogEvent result = mutableLogEventThreadLocal.get();
        if (result == null || result.reserved) {
            final boolean initThreadLocal = result == null;
            result = new MutableLogEvent();

            // usually no need to re-initialize thread-specific fields since 
the event is stored in a ThreadLocal
            result.setThreadId(Thread.currentThread().getId());
            result.setThreadName(Thread.currentThread().getName()); // 
Thread.getName() allocates Objects on each call
            result.setThreadPriority(Thread.currentThread().getPriority());
            if (initThreadLocal) {
                mutableLogEventThreadLocal.set(result);
            }
        }
        result.reserved = true;
        result.clear(); // ensure any previously cached values (thrownProxy, 
source, etc.) are cleared

        result.setLoggerName(loggerName);
        result.setMarker(marker);
...
{code}

The call {{result.clear()}} resets the argument-array based on data managed  
{{MutableLogEvent}}


> Multiple loggings of arguments are setting these arguments to null
> ------------------------------------------------------------------
>
>                 Key: LOG4J2-1688
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1688
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.7
>            Reporter: Stefan Hammelbeck
>
> We are using SLF4J over log4j Version 2.7.
> Calling {{org.slf4j.Logger.error(someFormat, args)}} *twice* with an 
> {{Object[] args}}  causes all elements of {{args}} to be set to {{null}}.



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

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

Reply via email to