Program: 14422
Project: 14422
Buggy source:
public ReportArtEntity generateReportArt(final ReportArtEntity report){
  log.debug("String_Node_Str");
  final Map<String,VolumeArtEntity> volumeEntities=new HashMap<String,VolumeArtEntity>();
  foreachReportingVolumeCreateEvent(report.getEndMs(),new Predicate<ReportingVolumeCreateEvent>(){
    @Override public boolean apply(    final ReportingVolumeCreateEvent createEvent){
      if (!report.getZones().containsKey(createEvent.getAvailabilityZone())) {
        report.getZones().put(createEvent.getAvailabilityZone(),new AvailabilityZoneArtEntity());
      }
      AvailabilityZoneArtEntity zone=report.getZones().get(createEvent.getAvailabilityZone());
      ReportingUser reportingUser=ReportingUserDao.getInstance().getReportingUser(createEvent.getUserId());
      if (reportingUser == null) {
        log.error("String_Node_Str" + createEvent.getUserId());
      }
      ReportingAccount reportingAccount=ReportingAccountDao.getInstance().getReportingAccount(reportingUser.getAccountId());
      if (reportingAccount == null) {
        log.error("String_Node_Str" + reportingUser.getAccountId());
      }
      if (!zone.getAccounts().containsKey(reportingAccount.getName())) {
        zone.getAccounts().put(reportingAccount.getName(),new AccountArtEntity());
      }
      AccountArtEntity account=zone.getAccounts().get(reportingAccount.getName());
      if (!account.getUsers().containsKey(reportingUser.getName())) {
        account.getUsers().put(reportingUser.getName(),new UserArtEntity());
      }
      UserArtEntity user=account.getUsers().get(reportingUser.getName());
      VolumeArtEntity volume=new VolumeArtEntity(createEvent.getVolumeId());
      user.getVolumes().put(createEvent.getUuid(),volume);
      volumeEntities.put(createEvent.getUuid(),volume);
      return true;
    }
  }
);
  final Map<String,VolumeSnapshotUsageArtEntity> snapshotEntities=new HashMap<String,VolumeSnapshotUsageArtEntity>();
  final Map<String,Long> snapshotStartTimes=new HashMap<String,Long>();
  foreachReportingSnapshotCreateEvent(report.getEndMs(),new Predicate<ReportingVolumeSnapshotCreateEvent>(){
    @Override public boolean apply(    final ReportingVolumeSnapshotCreateEvent createEvent){
      if (createEvent.getTimestampMs() > report.getEndMs())       return true;
      VolumeSnapshotUsageArtEntity usage=new VolumeSnapshotUsageArtEntity();
      usage.setSizeGB(createEvent.getSizeGB());
      usage.setSnapshotNum(1);
      usage.setGBSecs(createEvent.getSizeGB() * (DurationCalculator.boundDuration(report.getBeginMs(),report.getEndMs(),createEvent.getTimestampMs()) / 1000));
      VolumeArtEntity volume=volumeEntities.get(createEvent.getVolumeUuid());
      volume.getSnapshotUsage().put(createEvent.getVolumeSnapshotId(),usage);
      snapshotEntities.put(createEvent.getUuid(),usage);
      snapshotStartTimes.put(createEvent.getUuid(),createEvent.getTimestampMs());
      return true;
    }
  }
);
  foreachReportingSnapshotDeleteEvent(report.getEndMs(),new Predicate<ReportingVolumeSnapshotDeleteEvent>(){
    @Override public boolean apply(    final ReportingVolumeSnapshotDeleteEvent deleteEvent){
      if (snapshotEntities.containsKey(deleteEvent.getUuid())) {
        VolumeSnapshotUsageArtEntity snap=snapshotEntities.get(deleteEvent.getUuid());
        long startTimeMs=snapshotStartTimes.get(deleteEvent.getUuid()).longValue();
        long duration=DurationCalculator.boundDuration(report.getBeginMs(),report.getEndMs(),startTimeMs,deleteEvent.getTimestampMs()) / 1000;
        snap.setGBSecs(snap.getSizeGB() * duration);
      }
      return true;
    }
  }
);
  for (  String zoneName : report.getZones().keySet()) {
    AvailabilityZoneArtEntity zone=report.getZones().get(zoneName);
    for (    String accountName : zone.getAccounts().keySet()) {
      AccountArtEntity account=zone.getAccounts().get(accountName);
      for (      String userName : account.getUsers().keySet()) {
        UserArtEntity user=account.getUsers().get(userName);
        for (        String volumeUuid : user.getVolumes().keySet()) {
          VolumeArtEntity volume=user.getVolumes().get(volumeUuid);
          for (          String snapId : volume.getSnapshotUsage().keySet()) {
            VolumeSnapshotUsageArtEntity snap=volume.getSnapshotUsage().get(snapId);
            updateUsageTotals(volume.getSnapshotTotals(),snap);
            updateUsageTotals(user.getUsageTotals().getSnapshotTotals(),snap);
            updateUsageTotals(account.getUsageTotals().getSnapshotTotals(),snap);
            updateUsageTotals(zone.getUsageTotals().getSnapshotTotals(),snap);
          }
        }
      }
    }
  }
  return report;
}

Fixed version (ground truth):
public ReportArtEntity generateReportArt(final ReportArtEntity report){
  log.debug("String_Node_Str");
  final Map<String,Long> snapshotEndTimes=new HashMap<String,Long>();
  foreachReportingSnapshotDeleteEvent(report.getEndMs(),new Predicate<ReportingVolumeSnapshotDeleteEvent>(){
    @Override public boolean apply(    final ReportingVolumeSnapshotDeleteEvent deleteEvent){
      snapshotEndTimes.put(deleteEvent.getUuid(),deleteEvent.getTimestampMs());
      return true;
    }
  }
);
  final Map<String,ReportingVolumeCreateEvent> volumeCreateEvents=new HashMap<String,ReportingVolumeCreateEvent>();
  foreachReportingVolumeCreateEvent(report.getEndMs(),new Predicate<ReportingVolumeCreateEvent>(){
    @Override public boolean apply(    final ReportingVolumeCreateEvent createEvent){
      volumeCreateEvents.put(createEvent.getUuid(),createEvent);
      return true;
    }
  }
);
  foreachReportingSnapshotCreateEvent(report.getEndMs(),new Predicate<ReportingVolumeSnapshotCreateEvent>(){
    @Override public boolean apply(    final ReportingVolumeSnapshotCreateEvent createEvent){
      long endTime=snapshotEndTimes.containsKey(createEvent.getUuid()) ? snapshotEndTimes.get(createEvent.getUuid()) : report.getEndMs();
      if (createEvent.getTimestampMs() <= report.getEndMs() && endTime >= report.getBeginMs() && volumeCreateEvents.containsKey(createEvent.getVolumeUuid())) {
        VolumeSnapshotUsageArtEntity usage=new VolumeSnapshotUsageArtEntity();
        usage.setSizeGB(createEvent.getSizeGB());
        usage.setSnapshotNum(1);
        long durationMs=Math.min(report.getEndMs(),endTime) - Math.max(report.getBeginMs(),createEvent.getTimestampMs());
        usage.setGBSecs(createEvent.getSizeGB() * (durationMs / 1000));
        VolumeArtEntity vol=addParentNodes(report,volumeCreateEvents.get(createEvent.getVolumeUuid()));
        vol.getSnapshotUsage().put(createEvent.getId(),usage);
      }
      return true;
    }
  }
);
  for (  String zoneName : report.getZones().keySet()) {
    AvailabilityZoneArtEntity zone=report.getZones().get(zoneName);
    for (    String accountName : zone.getAccounts().keySet()) {
      AccountArtEntity account=zone.getAccounts().get(accountName);
      for (      String userName : account.getUsers().keySet()) {
        UserArtEntity user=account.getUsers().get(userName);
        for (        String volumeUuid : user.getVolumes().keySet()) {
          VolumeArtEntity volume=user.getVolumes().get(volumeUuid);
          for (          String snapId : volume.getSnapshotUsage().keySet()) {
            VolumeSnapshotUsageArtEntity snap=volume.getSnapshotUsage().get(snapId);
            updateUsageTotals(volume.getSnapshotTotals(),snap);
            updateUsageTotals(user.getUsageTotals().getSnapshotTotals(),snap);
            updateUsageTotals(account.getUsageTotals().getSnapshotTotals(),snap);
            updateUsageTotals(zone.getUsageTotals().getSnapshotTotals(),snap);
          }
        }
      }
    }
  }
  return report;
}