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

Add ThreadContext.putIfNull(String, String)

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.13.0
    • API
    • None

    Description

      Provide a helper method that provides a 1-liner to put an identifier only if it is not currently set. This removes an if-check in all classes that share a design approach of assessing a uniqueId, such as request id, etc.

      if(!ThreadContext.containsKey("uniqueId")) {
         ThreadContext.put("uniqueId", generateUniqueId());
      }
      

      Proposed:

      ThreadContext.putIfNull("uniqueId", generateUniqueId());
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mattrpav Matt Pavlovich
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m