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

StringBuilder escapeJson performs unnecessary Memory Allocations

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.11.0
    • 2.11.1, 3.0.0
    • None
    • None
    • Patch

    Description

      The StringBuilders.escapeJson function currently uses the string builder's insert method to add elements to an existing builder for the purposes of escaping special characters.  Unfortunately, this leads to a loop that regularly expands the builder capacity, causing issues at scale.

      A better approach would do a first run through to compute the total space required for the addition and then fill that space using the current method.

      Attachments

        Issue Links

          Activity

            People

              ckozak Carter Kozak
              kmeurer Kevin Andrew Meurer
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: