java.util.ConcurrentModificationException

记一次报错

   private AjaxResult disCollectionCase(List<Long> taskIdList, List<Long> sysUserIds, Long allocateUserId) {
        //3查询员工已分配未完成用户数
        List<Map<String, Long>> maps = collectionCaseCenterMapper.selectCollectionUnFinishUserCount(sysUserIds);
        Map<Long, Long> userCountMap = new HashMap<>();
        for (Map<String, Long> map : maps) {
            userCountMap.put(map.get("sysUserId"), map.get("count"));
        }
        //调用分配方法返回Map
        Map<Long, List<Long>> longListMap = automaticSingleService.automaticSingle(taskIdList, sysUserIds, userCountMap);//批量分配保存用户
        for (Map.Entry<Long, List<Long>> entry : longListMap.entrySet()) {
            Long userId = entry.getKey();
            List<Long> caseIds = entry.getValue();
            if (CollectionUtils.isNotEmpty(caseIds)) {
                // 已经分配未回收的,不能再分配
                caseIds = this.filterDistributedList(caseIds);
                if(CollectionUtils.isNotEmpty(caseIds)){
                    //保存分配案件
                    collectionCaseCenterMapper.beachdisCollection(userId, caseIds);
                    //批量保存分配信息
                    batchSaveCollectionCaseRecord(userId, caseIds, allocateUserId);
                }
            }
        }
        return AjaxResult.success("{}:催收案件分配完成", DateUtil.getCurrentDate());
    }



    private List<Long> filterDistributedList(List<Long> caseIds) {

        List<Long> distributedList = collectionCaseRecordService.getDistributedList(caseIds);
        if(CollectionUtils.isNotEmpty(distributedList)){
             caseIds.removeAll(distributedList);
        }
        return caseIds;
    }

记一次查看同事代码报错问题

Map<Long, List> longListMap
由于返回的这个map value 是用的ArrayList中subList 在 function 2 中remove了
所以在后续removeAll 的过程中 抛出异常 因为 CollectionUtils.isNotEmpty 函数会调用
size() 方法 而 subList size() 函数 会检测 是否被 修改过 所以抛出了一个这个异常

private void checkForComodification() {
    if (ArrayList.this.modCount != this.modCount)
        throw new ConcurrentModificationException();
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值