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

StringBuilder escapeJson performs unnecessary Memory Allocations

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.11.0
    • Fix Version/s: 3.0.0, 2.11.1
    • Component/s: None
    • Labels:
      None
    • Flags:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: