Uploaded image for project: 'CMS'
  1. CMS
  2. CMS-8193

EditContentFunction is not thread-safe

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 4.0RC4
    • 3.8.1, 3.9, 4.0RC3
    • Workflow
    • None

      EditContentFunction is not thread-safe because of using SimpleDateFormat in class variables.

      We should do like in SolrIndexer class :

      private static final ThreadLocal<SimpleDateFormat> __DATE_FORMAT = new ThreadLocal<>();
      
      public static SimpleDateFormat dateFormat()
      {
          if (__DATE_FORMAT.get() == null)
          {
              __DATE_FORMAT.set(new SimpleDateFormat("yyyy-MM-dd"));
          }
          return __DATE_FORMAT.get();
      }

      Then use dateFormat() instead of DATE_FORMAT.

      If we have two threads using DATE_FORMAT at the same time, we get an exception.

            Unassigned Unassigned
            bmaurel Bérénice Maurel
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: