concurrentmodificationexception hashmap in java

Posted by chetan on Stack Overflow See other posts from Stack Overflow or by chetan
Published on 2010-05-13T11:36:16Z Indexed on 2010/05/13 12:44 UTC
Read the original article Hit count: 143

Filed under:

I write following code but when this run it generate concurrentmodificationexception

if( attendancePolicy.getType().equals( AttendanceConstants.EMPLOYEE_ATTENDANCE_POLICY ) ) {
    synchronized( attendancePolicy.getListEmployee() ) {
        for( EmployeeAttendancePolicy employeeAttendancePolicy : attendancePolicy.getListEmployee() ) {
            employeeInfo = employeeInfoSessionBeanLocal.findEmployeeInfoEntityByEmployeeInfoId( 
                    employeeAttendancePolicy.getEmployeeId() );

            if( employeeInfo != null ) {
                employeeAttendancePolicy.setEmpName( 
                        employeeInfo.getFirstName() + " " 
                        + employeeInfo.getMiddleName() + " "
                        + employeeInfo.getLastName() );

                company = companySessionBeanLocal.findCompanyById( employeeInfo.getCompanyId() );
                employeeAttendancePolicy.setCompanyName( company.getName() );

                department = departmentSessionBeanLocal.findDepartmentEntityByDepartmentId( 
                        employeeInfo.getDepartmentId() );
                employeeAttendancePolicy.setDepartmentName( department.getName() );
            }
            else {
                attendancePolicy.getListEmployee().remove( employeeAttendancePolicy );
            }
        }
    }
}

© Stack Overflow or respective owner

Related posts about java