Buggy code:
if ( ( config . reservationService . getTagGroups ( utilization ) . size ( ) ) == 0 ) { logger . info ( "Utilization<seq2seq4repair_space>${utilization}<seq2seq4repair_space>size<seq2seq4repair_space>is<seq2seq4repair_space>0,<seq2seq4repair_space>skipping..." ) ; return ; } ReadWriteData usageData = usageDataByProduct . get ( null ) ; ReadWriteData costData = costDataByProduct . get ( null ) ; Map < Account , List < Account > > reservationAccounts = config . accountService . getReservationAccounts ( ) ; Set < Account > reservationOwners = reservationAccounts . keySet ( ) ; Map < Account , List < Account > > reservationBorrowers = Maps . newHashMap ( ) ; for ( Account account : reservationAccounts . keySet ( ) ) { logger . info ( "Reservation<seq2seq4repair_space>account<seq2seq4repair_space>id:<seq2seq4repair_space>${account.id}" ) ; logger . info ( "Reservation<seq2seq4repair_space>account<seq2seq4repair_space>name:<seq2seq4repair_space>${account.name}" ) ; List < Account > list = reservationAccounts . get ( account ) ; for ( Account borrowingAccount : list ) { logger . info ( "Borrowing<seq2seq4repair_space>account<seq2seq4repair_space>id:<seq2seq4repair_space>${borrowingAccount.id}" ) ; logger . info ( "Reservation<seq2seq4repair_space>account<seq2seq4repair_space>name:<seq2seq4repair_space>${borrowingAccount.name}" ) ; if ( borrowingAccount . name . equals ( account . name ) ) continue ; List < Account > from = reservationBorrowers . get ( borrowingAccount ) ; if ( from == null ) { from = Lists . newArrayList ( ) ; reservationBorrowers . put ( borrowingAccount , from ) ; } from . add ( account ) ; } } logger . info ( "reservationBorrowers<seq2seq4repair_space>debug!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" ) ; <START_BUG> for ( Map . Entry < Account , List < Account > > entry : map . entrySet ( ) ) { <END_BUG> Account acc = entry . getKey ( ) ; logger . info ( "Account:<seq2seq4repair_space>${acc.id}<seq2seq4repair_space>${acc.name}" ) ; List < Account > accList = entry . getValue ( ) ; for ( Account accL : accList ) { System . out . println ( "Account<seq2seq4repair_space>to<seq2seq4repair_space>borrow<seq2seq4repair_space>from:<seq2seq4repair_space>${accL.id}<seq2seq4repair_space>${accL.name}" ) ; } } logger . info ( "Marking<seq2seq4repair_space>owner<seq2seq4repair_space>accounts..." ) ; Set < TagGroup > toMarkOwners = Sets . newTreeSet ( ) ; for ( TagGroup tagGroup : config . reservationService . getTagGroups ( utilization ) ) { logger . info ( "usageData.getNum()<seq2seq4repair_space>=<seq2seq4repair_space>${usageData.getNum()}" ) ; for ( int i = 0 ; i < ( usageData . getNum ( ) ) ; i ++ ) { Map < TagGroup , Double > usageMap = usageData . getData ( i ) ; Map < TagGroup , Double > costMap = costData . getData ( i ) ; Double existing = usageMap . get ( tagGroup ) ; logger . info ( "1)<seq2seq4repair_space>existing<seq2seq4repair_space>=<seq2seq4repair_space>${existing}" ) ; double value = ( existing == null ) ? 0 : existing ; logger . info ( "2)<seq2seq4repair_space>value<seq2seq4repair_space>=<seq2seq4repair_space>${value}" ) ; ReservationService . ReservationInfo reservation = config . reservationService . getReservation ( ( ( startMilli ) + ( i * ( AwsUtils . hourMillis ) ) ) , tagGroup , utilization ) ; double reservedUsed = Math . min ( value , reservation . capacity ) ; double reservedUnused = ( reservation . capacity ) - reservedUsed ; double bonusReserved = ( value > ( reservation . capacity ) ) ? value - ( reservation . capacity ) : 0 ; logger . info ( "3)<seq2seq4repair_space>reservedUsed<seq2seq4repair_space>=<seq2seq4repair_space>${reservedUsed}" ) ; logger . info ( "4)<seq2seq4repair_space>reservedUnused<seq2seq4repair_space>=<seq2seq4repair_space>${reservedUnused}" ) ; logger . info ( "5)<seq2seq4repair_space>bonusReserved<seq2seq4repair_space>=<seq2seq4repair_space>${bonusReserved}" ) ; if ( ( reservedUsed > 0 ) || ( existing != null ) ) { usageMap . put ( tagGroup , reservedUsed ) ; costMap . put ( tagGroup , ( reservedUsed * ( reservation . reservationHourlyCost ) ) ) ; } if ( reservedUnused > 0 ) { TagGroup unusedTagGroup = new TagGroup ( tagGroup . account , tagGroup . region , tagGroup . zone , tagGroup . product , Operation . getUnusedInstances ( utilization ) , tagGroup . usageType , null ) ; usageMap . put ( unusedTagGroup , reservedUnused ) ; costMap . put ( unusedTagGroup , ( reservedUnused * ( reservation . reservationHourlyCost ) ) ) ; } if ( bonusReserved > 0 ) { TagGroup bonusTagGroup = new TagGroup ( tagGroup . account , tagGroup . region , tagGroup . zone , tagGroup . product , Operation . getBonusReservedInstances ( utilization ) , tagGroup . usageType , null ) ; usageMap . put ( bonusTagGroup , bonusReserved ) ; costMap . put ( bonusTagGroup , ( bonusReserved * ( reservation . reservationHourlyCost ) ) ) ; } if ( ( reservation . capacity ) > 0 ) { TagGroup upfrontTagGroup = new TagGroup ( tagGroup . account , tagGroup . region , tagGroup . zone , tagGroup . product , Operation . getUpfrontAmortized ( utilization ) , tagGroup . usageType , null ) ; costMap . put ( upfrontTagGroup , ( ( reservation . capacity ) * ( reservation . upfrontAmortized ) ) ) ; } } toMarkOwners . add ( new TagGroup ( tagGroup . account , tagGroup . region , tagGroup . zone , tagGroup . product , Operation . getReservedInstances ( utilization ) , tagGroup . usageType , null ) ) ; } logger . info ( "Marking<seq2seq4repair_space>borrower<seq2seq4repair_space>accounts..." ) ; Set < TagGroup > toMarkBorrowing = Sets . newTreeSet ( ) ; for ( TagGroup tagGroup : usageData . getTagGroups ( ) ) { logger . info ( "a)<seq2seq4repair_space>!toMarkOwners.contains(tagGroup)<seq2seq4repair_space>${!toMarkOwners.contains(tagGroup)}<seq2seq4repair_space>" ) ; if ( ( ( ( tagGroup . resourceGroup ) == null ) && ( ( tagGroup . product ) == ( Product . ec2_instance ) ) ) && ( ( ( ( tagGroup . operation ) == ( Operation . getReservedInstances ( utilization ) ) ) && ( ! ( toMarkOwners . contains ( tagGroup ) ) ) ) || ( ( tagGroup . operation ) == ( Operation . getBonusReservedInstances ( utilization ) ) ) ) ) { logger . info ( "b)<seq2seq4repair_space>adding<seq2seq4repair_space>tag<seq2seq4repair_space>group" ) ; toMarkBorrowing . add ( tagGroup ) ; } } logger . info ( "-----------------------------------------------" ) ; logger . info ( "toMarkBorrowing<seq2seq4repair_space>size<seq2seq4repair_space>==<seq2seq4repair_space>${toMarkBorrowing.size()}" ) ; for ( TagGroup tagGroup : toMarkBorrowing ) { for ( int i = 0 ; i < ( usageData . getNum ( ) ) ; i ++ ) { Map < TagGroup , Double > usageMap = usageData . getData ( i ) ; Map < TagGroup , Double > costMap = costData . getData ( i ) ; logger . info ( "???????" ) ; logger . info ( "borrowing...<seq2seq4repair_space>${i}"

Fix:
for ( Map . Entry < Account , List < Account > > entry : reservationBorrowers . entrySet ( ) ) {