Remko Popma created LOG4J2-1412:
-----------------------------------

             Summary: Unbox ringbuffer size should be configurable
                 Key: LOG4J2-1412
                 URL: https://issues.apache.org/jira/browse/LOG4J2-1412
             Project: Log4j 2
          Issue Type: Improvement
          Components: API
    Affects Versions: 2.6
            Reporter: Remko Popma


The Unbox utility is meant to be used for primitive parameters to a logging 
call with a parameterized message, for example {{logger.debug("pi is {}", 
Unbox.box(Double.PI))}}.

Unbox is implemented with a ThreadLocal a ringbuffer of StringBuilders. By 
default, the ringbuffer has 16 slots. After 16 calls to {{Unbox.box()}} it 
reuses the first StringBuilder again, so there is a limit to how many things 
can be boxed before the call to Message.getFormattedMessage() breaks.

This needs to be better documented in the Unbox javadoc and the garbage-free 
manual page. Furthermore, there should be a mechanism to allow users to 
increase the size of the ringbuffer.

Finally, if Constants.ENABLE_THREADLOCALS is false we should not store non-JDK 
classes in ThreadLocals. The Unbox.State class breaks that principle.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to