Re: ConcurrentModificationException
The code for mergeAndSort is quite messy . It looks like this
private List<Result> mergeAndSort(List list, List otherList,String
engine)
{
Collection temp = new ArrayList(list);
Collection temporary = new ArrayList(otherList);
for(Iterator li = list.iterator(); li.hasNext();)
{
Result res = (Result)li.next();
String url = res.getURL();
String t = res.getTitle();
int position = res.getPosition();
for(Iterator y = otherList.iterator(); y.hasNext();)
{
Result result = (Result)y.next();
String URL = result.getURL();
String tit = result.getTitle();
int pos = result.getPosition();
if(URL.equals(url)||tit.equals(t))
{
res.setFoundon(engine);
res.setPosition(Math.min(position,pos));
otherList.remove(result);
// y.remove();
break;
}
}
mergedResults.add(res);
}
for(Iterator li = otherList.iterator(); li.hasNext();)
{
Result res = (Result)li.next();
mergedResults.add(res);
}
Collections.sort(mergedResults);
return mergedResults;
}
But even when I change the line otherList.remove(result) to
y.remove(result) .I still get the exception. It has me stumped.