Uploaded image for project: 'MyFaces Tomahawk'
  1. MyFaces Tomahawk
  2. TOMAHAWK-674

ConcurrentModificationException in ScheduleModel.load on access to 'days' TreeMap

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Schedule
    • None
    • all

    Description

      ConcurrentModificationException in ScheduleModel.load on access to 'days' TreeMap

      AbstractSchedule model days TreeMap throws ConcurrentModificationException when accessed from two requests at same time.

      Caused by: java.util.ConcurrentModificationException
      at java.util.TreeMap$PrivateEntryIterator.nextEntry(TreeMap.java:1031)
      at java.util.TreeMap$KeyIterator.next(TreeMap.java:1058)
      at com.jsfapp.web.faces.bean.ScheduleModel.load(ScheduleModel.java:204)
      at com.jsfapp.web.faces.bean.ScheduleModel.setMonth(ScheduleModel.java:174)
      at org.apache.myfaces.custom.schedule.model.AbstractScheduleModel.setSelectedDate(AbstractScheduleModel.java:118)
      at org.apache.myfaces.custom.schedule.model.AbstractScheduleModel.refresh(AbstractScheduleModel.java:410)

      Consider using this:

      public static <K,V> SortedMap<K,V> synchronizedSortedMap(SortedMap<K,V> m)

      Returns a synchronized (thread-safe) sorted map backed by the specified sorted map. In order to guarantee serial access, it is critical that all access to the backing sorted map is accomplished through the returned sorted map (or its views).

      It is imperative that the user manually synchronize on the returned sorted map when iterating over any of its collection views, or the collections views of any of its subMap, headMap or tailMap views.

      SortedMap m = Collections.synchronizedSortedMap(new HashSortedMap());
      ...
      Set s = m.keySet(); // Needn't be in synchronized block
      ...
      synchronized(m)

      { // Synchronizing on m, not s! Iterator i = s.iterator(); // Must be in synchronized block while (i.hasNext()) foo(i.next()); }

      or:

      SortedMap m = Collections.synchronizedSortedMap(new HashSortedMap());
      SortedMap m2 = m.subMap(foo, bar);
      ...
      Set s2 = m2.keySet(); // Needn't be in synchronized block
      ...
      synchronized(m)

      { // Synchronizing on m, not m2 or s2! Iterator i = s.iterator(); // Must be in synchronized block while (i.hasNext()) foo(i.next()); }

      --MG

      Attachments

        Activity

          People

            Unassigned Unassigned
            mgrouch Mikhail Grushinskiy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: