偶遇到 java.util.ConcurrentModificationException 的异常

时间:2021-04-01 16:58:18
今天在调试程序 遇到了如此问题  贴上代码来看看
稍后分析 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原因