Program: 89956
Project: 89956
Buggy source:
private void sendOndemandCostAlert(){
  if (ondemandThreshold == null || StringUtils.isEmpty(fromEmail) || StringUtils.isEmpty(alertEmails) || new Date().getTime() < lastAlertMillis() + AwsUtils.hourMillis * 24)   return;
  Map<Long,Map<Ec2InstanceReservationPrice.Key,Double>> ondemandCosts=getOndemandCosts(lastAlertMillis() + AwsUtils.hourMillis * 24);
  Long maxHour=null;
  double maxTotal=ondemandThreshold;
  for (  Long hour : ondemandCosts.keySet()) {
    double total=0;
    for (    Double value : ondemandCosts.get(hour).values())     total+=value;
    if (total > maxTotal) {
      maxHour=hour;
      maxTotal=total;
    }
  }
  if (maxHour != null) {
    NumberFormat numberFormat=NumberFormat.getNumberInstance(Locale.US);
    String subject=String.format("String_Node_Str",numberFormat.format(maxTotal),AwsUtils.dateFormatter.print(maxHour));
    StringBuilder body=new StringBuilder();
    body.append(String.format("String_Node_Str",numberFormat.format(maxTotal),AwsUtils.dateFormatter.print(maxHour)));
    TreeMap<Double,String> costs=Maps.newTreeMap();
    for (    Map.Entry<Ec2InstanceReservationPrice.Key,Double> entry : ondemandCosts.get(maxHour).entrySet()) {
      costs.put(entry.getValue(),entry.getKey().region + "String_Node_Str" + entry.getKey().usageType+ "String_Node_Str");
    }
    for (    Double cost : costs.descendingKeySet()) {
      if (cost > 0)       body.append(costs.get(cost)).append("String_Node_Str" + numberFormat.format(cost)).append("String_Node_Str");
    }
    body.append("String_Node_Str" + urlPrefix + "String_Node_Str");
    SendEmailRequest request=new SendEmailRequest();
    request.withSource(fromEmail);
    List<String> emails=Lists.newArrayList(alertEmails.split("String_Node_Str"));
    request.withDestination(new Destination(emails));
    request.withMessage(new Message(new Content(subject),new Body().withHtml(new Content(body.toString()))));
    AmazonSimpleEmailServiceClient emailService=AwsUtils.getAmazonSimpleEmailServiceClient();
    try {
      emailService.sendEmail(request);
      updateLastAlertMillis(maxHour);
      logger.info("String_Node_Str" + maxHour);
    }
 catch (    Exception e) {
      logger.error("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
private void sendOndemandCostAlert(){
  if (ondemandThreshold == null || StringUtils.isEmpty(fromEmail) || StringUtils.isEmpty(alertEmails) || endMilli < lastAlertMillis() + AwsUtils.hourMillis * 24)   return;
  Map<Long,Map<Ec2InstanceReservationPrice.Key,Double>> ondemandCosts=getOndemandCosts(lastAlertMillis() + AwsUtils.hourMillis);
  Long maxHour=null;
  double maxTotal=ondemandThreshold;
  for (  Long hour : ondemandCosts.keySet()) {
    double total=0;
    for (    Double value : ondemandCosts.get(hour).values())     total+=value;
    if (total > maxTotal) {
      maxHour=hour;
      maxTotal=total;
      logger.info("String_Node_Str" + AwsUtils.dateFormatter.print(hour) + "String_Node_Str"+ NumberFormat.getNumberInstance(Locale.US).format(total));
    }
 else     logger.info("String_Node_Str" + AwsUtils.dateFormatter.print(hour) + "String_Node_Str"+ NumberFormat.getNumberInstance(Locale.US).format(total));
  }
  if (maxHour != null) {
    NumberFormat numberFormat=NumberFormat.getNumberInstance(Locale.US);
    String subject=String.format("String_Node_Str",numberFormat.format(maxTotal),AwsUtils.dateFormatter.print(maxHour));
    StringBuilder body=new StringBuilder();
    body.append(String.format("String_Node_Str",numberFormat.format(maxTotal),AwsUtils.dateFormatter.print(maxHour)));
    TreeMap<Double,String> costs=Maps.newTreeMap();
    for (    Map.Entry<Ec2InstanceReservationPrice.Key,Double> entry : ondemandCosts.get(maxHour).entrySet()) {
      costs.put(entry.getValue(),entry.getKey().region + "String_Node_Str" + entry.getKey().usageType+ "String_Node_Str");
    }
    for (    Double cost : costs.descendingKeySet()) {
      if (cost > 0)       body.append(costs.get(cost)).append("String_Node_Str" + numberFormat.format(cost)).append("String_Node_Str");
    }
    body.append("String_Node_Str" + urlPrefix + "String_Node_Str");
    SendEmailRequest request=new SendEmailRequest();
    request.withSource(fromEmail);
    List<String> emails=Lists.newArrayList(alertEmails.split("String_Node_Str"));
    request.withDestination(new Destination(emails));
    request.withMessage(new Message(new Content(subject),new Body().withHtml(new Content(body.toString()))));
    AmazonSimpleEmailServiceClient emailService=AwsUtils.getAmazonSimpleEmailServiceClient();
    try {
      emailService.sendEmail(request);
      updateLastAlertMillis(endMilli);
      logger.info("String_Node_Str" + endMilli);
    }
 catch (    Exception e) {
      logger.error("String_Node_Str",e);
    }
  }
}