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

MarkerManager getMarker methods should avoid creating temporary objects

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.5
    • 2.6
    • API
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: