Program: 14505
Project: 14505
Buggy source:
/** 
 * <p>Gather a Map of all Instance resource usage for a period.
 */
public Map<InstanceSummaryKey,InstanceUsageSummary> getUsageSummaryMap(Period period,String accountId){
  log.info("String_Node_Str" + period);
  final Map<InstanceSummaryKey,InstanceUsageSummary> usageMap=new HashMap<InstanceSummaryKey,InstanceUsageSummary>();
  EntityWrapper<InstanceUsageSnapshot> entityWrapper=EntityWrapper.get(InstanceUsageSnapshot.class);
  try {
    long latestSnapshotBeforeMs=findLatestAllSnapshotBefore(period.getBeginningMs());
    long afterEnd=period.getEndingMs() + ((period.getBeginningMs() - latestSnapshotBeforeMs) * 2);
    log.debug("String_Node_Str" + latestSnapshotBeforeMs + "String_Node_Str"+ afterEnd);
    @SuppressWarnings("String_Node_Str") List list=null;
    if (accountId == null) {
      list=entityWrapper.createQuery("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str").setLong(0,latestSnapshotBeforeMs).setLong(1,afterEnd).list();
    }
 else {
      list=entityWrapper.createQuery("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str").setString(0,accountId).setLong(1,latestSnapshotBeforeMs).setLong(2,afterEnd).list();
    }
    Map<String,InstanceDataAccumulator> dataAccumulatorMap=new HashMap<String,InstanceDataAccumulator>();
    for (    Object obj : list) {
      Object[] row=(Object[])obj;
      InstanceAttributes insAttrs=(InstanceAttributes)row[0];
      InstanceUsageSnapshot snapshot=(InstanceUsageSnapshot)row[1];
      log.debug("String_Node_Str" + insAttrs + "String_Node_Str"+ snapshot);
      String uuid=insAttrs.getUuid();
      if (!dataAccumulatorMap.containsKey(uuid)) {
        InstanceDataAccumulator accumulator=new InstanceDataAccumulator(insAttrs,snapshot,period);
        dataAccumulatorMap.put(uuid,accumulator);
      }
 else {
        InstanceDataAccumulator accumulator=dataAccumulatorMap.get(uuid);
        accumulator.update(snapshot);
      }
    }
    for (    String uuid : dataAccumulatorMap.keySet()) {
      InstanceDataAccumulator accumulator=dataAccumulatorMap.get(uuid);
      InstanceSummaryKey key=new InstanceSummaryKey(accumulator.getInstanceAttributes());
      if (!usageMap.containsKey(key)) {
        usageMap.put(key,new InstanceUsageSummary());
      }
      InstanceUsageSummary ius=usageMap.get(key);
      ius.addDiskIoMegs(accumulator.getDiskIoMegs());
      ius.addNetworkIoMegs(accumulator.getNetIoMegs());
      ius.sumFromPeriodType(accumulator.getDurationPeriod(),accumulator.getInstanceAttributes().getInstanceType());
    }
    entityWrapper.commit();
  }
 catch (  Exception ex) {
    log.error(ex);
    entityWrapper.rollback();
    throw new RuntimeException(ex);
  }
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str");
    for (    InstanceSummaryKey key : usageMap.keySet()) {
      log.debug("String_Node_Str" + key + "String_Node_Str"+ usageMap.get(key));
    }
  }
  return usageMap;
}

Fixed version (ground truth):
/** 
 * <p>Gather a Map of all Instance resource usage for a period.
 */
public Map<InstanceSummaryKey,InstanceUsageSummary> getUsageSummaryMap(Period period,String accountId){
  log.info("String_Node_Str" + period);
  final Map<InstanceSummaryKey,InstanceUsageSummary> usageMap=new HashMap<InstanceSummaryKey,InstanceUsageSummary>();
  EntityWrapper<InstanceUsageSnapshot> entityWrapper=EntityWrapper.get(InstanceUsageSnapshot.class);
  try {
    long latestSnapshotBeforeMs=findLatestAllSnapshotBefore(period.getBeginningMs());
    long afterEnd=period.getEndingMs() + ((period.getBeginningMs() - latestSnapshotBeforeMs) * 2);
    log.debug("String_Node_Str" + latestSnapshotBeforeMs + "String_Node_Str"+ afterEnd);
    @SuppressWarnings("String_Node_Str") List list=null;
    if (accountId == null) {
      list=entityWrapper.createQuery("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str").setLong(0,latestSnapshotBeforeMs).setLong(1,afterEnd).list();
    }
 else {
      list=entityWrapper.createQuery("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str").setString(0,accountId).setLong(1,latestSnapshotBeforeMs).setLong(2,afterEnd).list();
    }
    Map<String,InstanceDataAccumulator> dataAccumulatorMap=new HashMap<String,InstanceDataAccumulator>();
    for (    Object obj : list) {
      Object[] row=(Object[])obj;
      InstanceAttributes insAttrs=(InstanceAttributes)row[0];
      InstanceUsageSnapshot snapshot=(InstanceUsageSnapshot)row[1];
      log.debug("String_Node_Str" + insAttrs + "String_Node_Str"+ snapshot);
      String uuid=insAttrs.getUuid();
      if (!dataAccumulatorMap.containsKey(uuid)) {
        InstanceDataAccumulator accumulator=new InstanceDataAccumulator(insAttrs,snapshot,period);
        dataAccumulatorMap.put(uuid,accumulator);
      }
 else {
        InstanceDataAccumulator accumulator=dataAccumulatorMap.get(uuid);
        accumulator.update(snapshot);
      }
    }
    for (    String uuid : dataAccumulatorMap.keySet()) {
      log.debug("String_Node_Str" + uuid);
      InstanceDataAccumulator accumulator=dataAccumulatorMap.get(uuid);
      InstanceSummaryKey key=new InstanceSummaryKey(accumulator.getInstanceAttributes());
      if (!usageMap.containsKey(key)) {
        usageMap.put(key,new InstanceUsageSummary());
      }
      InstanceUsageSummary ius=usageMap.get(key);
      ius.addDiskIoMegs(accumulator.getDiskIoMegs());
      ius.addNetworkIoMegs(accumulator.getNetIoMegs());
      ius.sumFromPeriodType(accumulator.getDurationPeriod(),accumulator.getInstanceAttributes().getInstanceType());
    }
    entityWrapper.commit();
  }
 catch (  Exception ex) {
    log.error(ex);
    entityWrapper.rollback();
    throw new RuntimeException(ex);
  }
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str");
    for (    InstanceSummaryKey key : usageMap.keySet()) {
      log.debug("String_Node_Str" + key + "String_Node_Str"+ usageMap.get(key));
    }
  }
  return usageMap;
}