代码改变世界

偶遇到 java.util.ConcurrentModificationException 的异常

2016-12-26 12:43  VinpleZhang  阅读(352)  评论(0编辑  收藏  举报
今天在调试程序 遇到了如此问题  贴上代码来看看
稍后分析

List<String> list = null;
boolean isUpdate = false;
try {
list = JSON.parse(var.getValue(), ArrayList.class);
if(CollectionUtils.isNotEmpty(list)){
for (String workno : list) {
if (cmd.getUserId().toString().equals(workno)) {
isUpdate = true;
list.remove(workno);
//排除重复
if (!list.contains(cmd.getTransferUserId().toString())) {
list.add(cmd.getTransferUserId().toString());
}
}
}
map.put(var.getName(), JSON.json(list));
}
} catch (ParseException e) {
log.warn("Admin|doTransPermissions|Exception", e);
throw new UedException(e);
} catch (IOException e) {
log.warn("Admin|doTransPermissions|Exception", e);
throw new UedException(e);
}java.util.ConcurrentModificationException原因