Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
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)
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)
--MG