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

FixedDateFormat improvements

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.6
    • 2.8.1
    • Pattern Converters
    • None

    Description

      Proposed changes:

      • improve thread-safety of FixedDateFormat::updateMidnightMillis
      • expose FixedDateFormat::millisSinceMidnight as a public method

      In multi-threaded scenarios where time does not move forward monotonically, the implementation of FixedDateFormat::updateMidnightMillis can result in corrupted time stamps. In a project I am involved in we have a custom PatternConverter that uses FixedDateFormat to format the "event time". In these (artificial) tests, event time does not always move forward, so the updateMidnightMillis is called concurrently with varying values. This is not a production issue, but the implementation can be improved to be thread-safe without impacting performance by using double-checked locking.

      Making FixedDateFormat::millisSinceMidnight public would provide a performant and convenient way to strip off the date component. Useful for systems that are on Java 7 or for systems on Java 8 that don't want to construct a LocalTime object every time this value is required.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: