Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1412

Unbox ringbuffer size should be configurable

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.6, 2.6.1
    • 2.6.2
    • API
    • None

    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

          Activity

            People

              rpopma Remko Popma
              rpopma Remko Popma
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: