Buggy code:
public byte [ ] generateXmlFileByOsceId ( Long osceId , Osce osce ) { } private void exportExam ( ObjectFactory factory , Oscedata oscedata , Osce osce ) { } private void exportChecklist ( ObjectFactory factory , Oscedata oscedata , Long osceId ) { } private void exportChecklistItemBean ( ObjectFactory factory , ChecklistItem checklistItem , Checklistitem checklistitemBean ) { } private void exportChecklistItemsChild ( List < ChecklistItem > checklistItems , Checklistitem checklistitemParentBean , ObjectFactory factory ) { } private void exportExaminers ( Long osceId , ObjectFactory factory , Oscedata oscedata ) { } private void exportCandidates ( Long osceId , ObjectFactory factory , Oscedata oscedata ) { } private void exportStations ( Long osceId , ObjectFactory factory , Oscedata oscedata ) { } private void exportCourses ( Long osceId , ObjectFactory factory , Oscedata oscedata , OsceConstantsWithLookup constants ) { } private void exportRotations ( Long osceId , ObjectFactory factory , Oscedata oscedata , OsceConstantsWithLookup constants ) { ExportiOSCEXml . Log . info ( "export<seq2seq4repair_space>exportRotations<seq2seq4repair_space>at<seq2seq4repair_space>:<seq2seq4repair_space>StandardizedRole" ) ; Osce osce = Osce . findOsce ( osceId ) ; List < OsceDay > osceDayList = OsceDay . findOsceDayByOsce ( osceId ) ; int startrotation = 0 ; int totalrotation = 0 ; Rotations rotationsBean = factory . createOscedataRotations ( ) ; oscedata . setRotations ( rotationsBean ) ; for ( int j = 0 ; j < ( osceDayList . size ( ) ) ; j ++ ) { OsceDay osceDay = osceDayList . get ( j ) ; List < OsceSequence > sequenceList = OsceSequence . findOsceSequenceByOsceDay ( osceDay . getId ( ) ) ; for ( int k = 0 ; k < ( sequenceList . size ( ) ) ; k ++ ) { startrotation = totalrotation ; totalrotation = totalrotation + ( sequenceList . get ( k ) . getNumberRotation ( ) ) ; List < Course > courseList = sequenceList . get ( k ) . getCourses ( ) ; for ( Course course : courseList ) { for ( int l = startrotation ; l < totalrotation ; l ++ ) { Rotation rotationBean = factory . createOscedataRotationsRotation ( ) ; rotationsBean . getRotation ( ) . add ( rotationBean ) ; rotationBean . setId ( Long . parseLong ( ( ( ( l + 1 ) + "" ) + ( course . getId ( ) ) ) ) ) ; rotationBean . setTitle ( ( ( ( "Rotation<seq2seq4repair_space>" + ( String . format ( "%02d" , ( l + 1 ) ) ) ) + "<seq2seq4repair_space>" ) + ( constants . getString ( course . getColor ( ) ) ) ) ) ; rotationBean . setCourseId ( course . getId ( ) ) ; rotationBean . setOsceDayId ( osceDay . getId ( ) ) ; List < Date > timeList = Assignment . findMinTimeStartAndMaxTimeEndByOsceDayAndRotationNumber ( osceDay . getId ( ) , l ) ; if ( ( timeList . size ( ) ) == 2 ) { if ( ( timeList . get ( 0 ) ) != null ) { String timeStart = ExportiOSCEXml . DATE_FORMAT . format ( timeList . get ( 0 ) ) ; rotationBean . setStartTime ( timeStart ) ; } else { rotationBean . setStartTime ( "" ) ; } if ( ( timeList . get ( 1 ) ) != null ) { String timeEnd = ExportiOSCEXml . DATE_FORMAT . format ( timeList . get ( 1 ) ) ; rotationBean . setEndTime ( timeEnd ) ; } else { rotationBean . setEndTime ( "" ) ; } } else { rotationBean . setStartTime ( "" ) ; rotationBean . setEndTime ( "" ) ; } Oscedata . Rotations . Rotation . Stations stationsBean = factory . createOscedataRotationsRotationStations ( ) ; rotationBean . setStations ( stationsBean ) ; <START_BUG> List < OscePostRoom > oscePostRoomList = OscePostRoom . findOscePostRoomByCourseID ( course . getId ( ) ) ; <END_BUG> for ( OscePostRoom oscePostRoom : oscePostRoomList ) { Oscedata . Rotations . Rotation . Stations . Station stationBean = factory . createOscedataRotationsRotationStationsStation ( ) ; stationsBean . getStation ( ) . add ( stationBean ) ; stationBean . setId ( oscePostRoom . getId ( ) ) ; List < Assignment > assignmentlist = Assignment . findAssignmentByOscePostRoom ( oscePostRoom . getId ( ) , osceId , l ) ; List < Assignment > examinerAssList = new ArrayList < Assignment > ( ) ; if ( ( assignmentlist . size ( ) ) > 0 ) { for ( int i = 0 ; i < ( ( assignmentlist . size ( ) ) - 1 ) ; i ++ ) { Assignment startAss = assignmentlist . get ( i ) ; if ( ( i + 1 ) < ( assignmentlist . size ( ) ) ) { Assignment endAss = assignmentlist . get ( ( i + 1 ) ) ; long mins = diffInMinBetweenTwoDate ( startAss . getTimeEnd ( ) , endAss . getTimeStart ( ) ) ; if ( mins > ( osce . getShortBreak ( ) ) ) { String breakTimeStart = ExportiOSCEXml . DATE_FORMAT . format ( startAss . getTimeEnd ( ) ) ; String breakTimeEnd = ExportiOSCEXml . DATE_FORMAT . format ( endAss . getTimeStart ( ) ) ; rotationBean . setBreakStartTime ( breakTimeStart ) ; rotationBean . setBreakEndTime ( breakTimeEnd ) ; } } } Date timestart = assignmentlist . get ( 0 ) . getTimeStart ( ) ; Date timeend = assignmentlist . get ( ( ( assignmentlist . size ( ) ) - 1 ) ) . getTimeEnd ( ) ; examinerAssList = Assignment . findAssignmentExamnierByOscePostRoom ( oscePostRoom . getId ( ) , osceId , timestart , timeend ) ; } for ( Assignment examinerAss : examinerAssList ) { if ( ( examinerAss . getExaminer ( ) ) != null ) { stationBean . setExaminerId ( examinerAss . getExaminer ( ) . getId ( ) ) ; break ; } }

Fix:
List < OscePostRoom > oscePostRoomList = OscePostRoom . findOscePostRoomByCourseIDForIOSCE ( course . getId ( ) ) ;