Program: 14457
Project: 14457
Buggy source:
public ReportArtEntity generateReportArt(ReportArtEntity report){
  log.debug("String_Node_Str");
  EntityWrapper wrapper=EntityWrapper.get(ReportingS3ObjectCreateEvent.class);
  Iterator iter=wrapper.scanWithNativeQuery("String_Node_Str");
  Map<String,BucketUsageArtEntity> bucketUsageEntities=new HashMap<String,BucketUsageArtEntity>();
  Map<S3ObjectKey,S3ObjectData> objectData=new HashMap<S3ObjectKey,S3ObjectData>();
  DurationCalculator<S3ObjectKey> objectDurationCalculator=new DurationCalculator<S3ObjectKey>();
  while (iter.hasNext()) {
    ReportingS3ObjectCreateEvent createEvent=(ReportingS3ObjectCreateEvent)iter.next();
    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 (!report.getAccounts().containsKey(reportingAccount.getName())) {
      report.getAccounts().put(reportingAccount.getName(),new AccountArtEntity());
    }
    AccountArtEntity account=report.getAccounts().get(reportingAccount.getName());
    if (!account.getUsers().containsKey(reportingUser.getName())) {
      account.getUsers().put(reportingUser.getName(),new UserArtEntity());
    }
    UserArtEntity user=account.getUsers().get(reportingUser.getName());
    if (!user.getBucketUsage().containsKey(createEvent.getS3BucketName())) {
      user.getBucketUsage().put(createEvent.getS3BucketName(),new BucketUsageArtEntity());
    }
    BucketUsageArtEntity bucketUsage=user.getBucketUsage().get(createEvent.getS3BucketName());
    bucketUsageEntities.put(createEvent.getS3BucketName(),bucketUsage);
    S3ObjectKey objectKey=new S3ObjectKey(createEvent.getS3BucketName(),createEvent.getS3ObjectKey(),createEvent.getObjectVersion());
    objectDurationCalculator.addStart(objectKey,createEvent.getTimestampMs());
    objectData.put(objectKey,new S3ObjectData((createEvent.getSizeGB() - report.getEndMs()),createEvent.getSizeGB()));
  }
  iter=wrapper.scanWithNativeQuery("String_Node_Str");
  while (iter.hasNext()) {
    ReportingS3ObjectDeleteEvent deleteEvent=(ReportingS3ObjectDeleteEvent)iter.next();
    if (deleteEvent.getTimestampMs() < report.getEndMs()) {
      S3ObjectKey key=new S3ObjectKey(deleteEvent.getS3BucketName(),deleteEvent.getS3ObjectKey(),deleteEvent.getObjectVersion());
      long objDurationMs=objectDurationCalculator.getDuration(key,deleteEvent.getTimestampMs());
      if (objectData.containsKey(key)) {
        objectData.get(key).incrementDurationMs(objDurationMs);
      }
    }
  }
  for (  S3ObjectKey objKey : objectData.keySet()) {
    S3ObjectData data=objectData.get(objKey);
    if (bucketUsageEntities.containsKey(objKey.getBucketName())) {
      BucketUsageArtEntity usage=bucketUsageEntities.get(objKey.getBucketName());
      usage.setObjectsNum(usage.getObjectsNum() + 1);
      long gBSecs=(data.getDurationMs() / 1000) * data.getSizeGB();
      usage.setGBSecs(gBSecs);
      usage.setSizeGB(usage.getSizeGB() + data.getSizeGB());
    }
 else {
      log.error("String_Node_Str" + objKey.getBucketName());
    }
  }
  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 bucketName : user.getBucketUsage().keySet()) {
          BucketUsageArtEntity usage=user.getBucketUsage().get(bucketName);
          updateUsageTotals(user.getUsageTotals().getBucketTotals(),usage);
          updateUsageTotals(account.getUsageTotals().getBucketTotals(),usage);
          updateUsageTotals(zone.getUsageTotals().getBucketTotals(),usage);
        }
      }
    }
  }
  return report;
}

Fixed version (ground truth):
public ReportArtEntity generateReportArt(ReportArtEntity report){
  log.debug("String_Node_Str");
  EntityWrapper wrapper=EntityWrapper.get(ReportingS3ObjectCreateEvent.class);
  Iterator iter=wrapper.scanWithNativeQuery("String_Node_Str");
  Map<String,BucketUsageArtEntity> bucketUsageEntities=new HashMap<String,BucketUsageArtEntity>();
  Map<S3ObjectKey,S3ObjectData> objectData=new HashMap<S3ObjectKey,S3ObjectData>();
  DurationCalculator<S3ObjectKey> objectDurationCalculator=new DurationCalculator<S3ObjectKey>(report.getEndMs());
  while (iter.hasNext()) {
    ReportingS3ObjectCreateEvent createEvent=(ReportingS3ObjectCreateEvent)iter.next();
    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 (!report.getAccounts().containsKey(reportingAccount.getName())) {
      report.getAccounts().put(reportingAccount.getName(),new AccountArtEntity());
    }
    AccountArtEntity account=report.getAccounts().get(reportingAccount.getName());
    if (!account.getUsers().containsKey(reportingUser.getName())) {
      account.getUsers().put(reportingUser.getName(),new UserArtEntity());
    }
    UserArtEntity user=account.getUsers().get(reportingUser.getName());
    if (!user.getBucketUsage().containsKey(createEvent.getS3BucketName())) {
      user.getBucketUsage().put(createEvent.getS3BucketName(),new BucketUsageArtEntity());
    }
    BucketUsageArtEntity bucketUsage=user.getBucketUsage().get(createEvent.getS3BucketName());
    bucketUsageEntities.put(createEvent.getS3BucketName(),bucketUsage);
    S3ObjectKey objectKey=new S3ObjectKey(createEvent.getS3BucketName(),createEvent.getS3ObjectKey(),createEvent.getObjectVersion());
    objectDurationCalculator.addStart(objectKey,createEvent.getTimestampMs());
    objectData.put(objectKey,new S3ObjectData(createEvent.getSizeGB()));
  }
  iter=wrapper.scanWithNativeQuery("String_Node_Str");
  while (iter.hasNext()) {
    ReportingS3ObjectDeleteEvent deleteEvent=(ReportingS3ObjectDeleteEvent)iter.next();
    if (deleteEvent.getTimestampMs() < report.getEndMs()) {
      S3ObjectKey key=new S3ObjectKey(deleteEvent.getS3BucketName(),deleteEvent.getS3ObjectKey(),deleteEvent.getObjectVersion());
      objectDurationCalculator.addEnd(key,deleteEvent.getTimestampMs());
    }
  }
  Map<S3ObjectKey,Long> durationMap=objectDurationCalculator.getDurationMap();
  for (  S3ObjectKey key : durationMap.keySet()) {
    if (objectData.containsKey(key)) {
      objectData.get(key).setDurationMs(durationMap.get(key));
    }
  }
  for (  S3ObjectKey objKey : objectData.keySet()) {
    S3ObjectData data=objectData.get(objKey);
    if (bucketUsageEntities.containsKey(objKey.getBucketName())) {
      BucketUsageArtEntity usage=bucketUsageEntities.get(objKey.getBucketName());
      usage.setObjectsNum(usage.getObjectsNum() + 1);
      long gBSecs=(data.getDurationMs() / 1000) * data.getSizeGB();
      usage.setGBSecs(gBSecs);
      usage.setSizeGB(usage.getSizeGB() + data.getSizeGB());
    }
 else {
      log.error("String_Node_Str" + objKey.getBucketName());
    }
  }
  for (  String accountName : report.getAccounts().keySet()) {
    AccountArtEntity account=report.getAccounts().get(accountName);
    for (    String userName : account.getUsers().keySet()) {
      UserArtEntity user=account.getUsers().get(userName);
      for (      String bucketName : user.getBucketUsage().keySet()) {
        BucketUsageArtEntity usage=user.getBucketUsage().get(bucketName);
        updateUsageTotals(user.getUsageTotals().getBucketTotals(),usage);
        updateUsageTotals(account.getUsageTotals().getBucketTotals(),usage);
      }
    }
  }
  return report;
}