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

ParameterizedMessage optimization

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5
    • 2.6
    • API
    • None

    Description

      ParameterizedMessage creates unnecessary objects and does other unnecessary work in its constructor.
      On the other hand, it does not create the full formatted string it will eventually need to return from getFormattedMessage().

      I propose the following changes:

      • Don't call argumentsToStrings in the constructor. Converting the parameter Object[] array to a String[] array should only be done when necessary: when this ParameterizedMessage is serialized.
      • Don't copy the parameter Object[] array to a new array. Instead clone the array when the getParameters() method is called.
      • In the constructor, build the fully formatted message. This combines the work done by formatStringArgs(String, String[]) and argumentsToStrings(Object[]) and avoids the issue mentioned in LOG4J2-763.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: