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

MarkerManager getMarker methods should avoid creating temporary objects

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5
    • Fix Version/s: 2.6
    • Component/s: API
    • Labels:
      None

      Description

      Currently MarkerManager's get methods create a new Marker object for each invocation.

      I propose to change this as follows:

      // current
      public static Marker getMarker(final String name) {
          MARKERS.putIfAbsent(name, new Log4jMarker(name));
          return MARKERS.get(name);
      }
      
      // proposed
      public static Marker getMarker(final String name) {
          Marker result = MARKERS.get(name);
          if (result == null) {
              MARKERS.putIfAbsent(name, new Log4jMarker(name));
              result = MARKERS.get(name);
          }
          return result;
      }
      

        Attachments

          Activity

            People

            • Assignee:
              remkop@yahoo.com Remko Popma
              Reporter:
              remkop@yahoo.com Remko Popma
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: