Uploaded image for project: 'Apache Roller'
  1. Apache Roller
  2. ROL-1207

unsafe multi-threaded usage of SimpleDateFormat in cache filter code

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.3
    • 3.0
    • None

    Description

      While fixing ROL-1201, I also noticed that the SimpleDateFormat used is shared. This is a well known and documented badness. It's not designed to be safe for sharing across threads.

      In the present case calling format() sets an internal Calendar object with the time, yielding unpredictable results in the shared MT case.

      All of the IfModified*Filter classes have this bug.

      Instantiating SimpleDateFormat with the given expression is a bit expensive, but measurement indicates it takes only about 24 microseconds per instantiation (averaged over 100000 iterations) on my two-year-old home pc. I think we can afford it, and I don't know how many times we are thinking we are missing the cache because of MT access screwing up the result.

      Attachments

        Activity

          People

            agangolli Anil Gangolli
            agangolli Anil Gangolli
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: