Description
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.
Attachments
Issue Links
- relates to
-
LOG4J2-1417 Unbox should respect Constants.ENABLE_THREADLOCALS
- Closed