java.util.ConcurrentModificationException Issue
While running the following code snippet at some scenario, I got the java.util.ConcurrentModificationException exception.
Please advice: How to avoid it? what can be the worse scenario which ConcurrentModificationException can create? will it occupy the CPU Usage %? Any pointer would be great!!!
Code java:
public Map someMethod()
{
Map actionDosMap =new HashMap();
List associatedActionsDos =new ArrayList();
List associatedActionsPerformanceDos =new ArrayList();
Iterator iterActions =associatedActions.iterator();
while (iterActions.hasNext())
{
Iterator reposIt = reposSet.iterator();
while (reposIt.hasNext()) {
RepoRow row = (RepoRow) reposIt.next();
Properties props = row.getProperties();
DoData performanceReportsDo = new DoData();
if ("PerformanceReports".equals(props.getStringValue(do_type))) {
performanceReportsDo.setDoType(doType);
performanceReportsDo.setDoId(doID);
associatedActionsPerformanceDos.add(performanceReportsDo);
}
else
{
DoData doc = new DoData();
doc.setDoType(doType);
doc.setDoId(doID);
associatedActionsDos.add(doc);
}
}
}
actionDosMap.put("performanceReportsDo",associatedActionsPerformanceDos);
actionDosMap.put("actionsNonPerfoDo",associatedActionsDos);
return actionDosMap;
}
Re: java.util.ConcurrentModificationException Issue
Read the API for ConcurrentModificationException, in particular the mention of iterators, which may be the problem here. Your variables are not well defined in the above, so this is a guess but you are probably modifying a list while iterating through the iterator of said list.