Program: 18536
Project: 18536
Buggy source:
@Override public List<MetricGraphData> getMetricValue(CriteriaInfo criteriaInfo,long beginTime,long duration,int aggregationPeriod,String autoDelay){
  List<MetricGraphData> result=new ArrayList<MetricGraphData>();
  String encodedMetricName=criteriaInfo.getMetricName();
  String metricName=decodeMetricName(encodedMetricName);
  long endTime=beginTime + TimeUnit.SECONDS.toMillis(duration);
  boolean serverSide=MonitoringSystem.COLLECTION_LOCATION_SERVER.equals(criteriaInfo.getRoleType());
  Map<String,List<String>> filters=new HashMap<String,List<String>>();
  if (criteriaInfo.getServiceName() != null)   filters.put("String_Node_Str",Arrays.asList(criteriaInfo.getServiceName().trim()));
  if (criteriaInfo.getOperationName() != null)   filters.put("String_Node_Str",Arrays.asList(criteriaInfo.getOperationName().trim()));
  if (criteriaInfo.getConsumerName() != null)   filters.put("String_Node_Str",Arrays.asList(criteriaInfo.getConsumerName().trim()));
  Map<String,List<MetricValue<?>>> metricValuesByOperationName;
  try {
    metricValuesByOperationName=metricValuesDAO.findMetricValuesByOperation(metricName,beginTime,endTime,serverSide,aggregationPeriod,filters);
    List<MetricValue<?>> metricValues=metricValuesByOperationName.get(criteriaInfo.getOperationName());
    for (int i=0; i < duration / aggregationPeriod; ++i) {
      long startTime=beginTime + TimeUnit.SECONDS.toMillis(i * aggregationPeriod);
      long stopTime=startTime + TimeUnit.SECONDS.toMillis(aggregationPeriod);
      double value=0;
      for (      MetricValue<?> metricValue : metricValues) {
        long time=metricValue.getTimeMiliseconds();
        if (startTime <= time && time < stopTime) {
          value+=(Double)metricValue.getValueForMetric(encodedMetricName);
          break;
        }
      }
      MetricGraphData metricGraphData=new MetricGraphData();
      metricGraphData.setCount(value);
      metricGraphData.setTimeSlot(startTime);
      metricGraphData.setCriteria(null);
      result.add(metricGraphData);
    }
  }
 catch (  ServiceException e) {
    e.printStackTrace();
  }
  return result;
}

Fixed version (ground truth):
@Override public List<MetricGraphData> getMetricValue(CriteriaInfo criteriaInfo,long beginTime,long duration,int aggregationPeriod,String autoDelay){
  List<MetricGraphData> result=new ArrayList<MetricGraphData>();
  String encodedMetricName=criteriaInfo.getMetricName();
  String metricName=decodeMetricName(encodedMetricName);
  long endTime=beginTime + TimeUnit.SECONDS.toMillis(duration);
  boolean serverSide=MonitoringSystem.COLLECTION_LOCATION_SERVER.equals(criteriaInfo.getRoleType());
  Map<String,List<String>> filters=new HashMap<String,List<String>>();
  if (criteriaInfo.getServiceName() != null)   filters.put("String_Node_Str",Arrays.asList(criteriaInfo.getServiceName().trim()));
  if (criteriaInfo.getOperationName() != null)   filters.put("String_Node_Str",Arrays.asList(criteriaInfo.getOperationName().trim()));
  if (criteriaInfo.getConsumerName() != null)   filters.put("String_Node_Str",Arrays.asList(criteriaInfo.getConsumerName().trim()));
  Map<String,List<MetricValue<?>>> metricValuesByOperationName;
  try {
    List<String> operationNames=filters.get("String_Node_Str");
    if (operationNames == null || operationNames.isEmpty()) {
      List<String> serviceNames=filters.get("String_Node_Str");
      operationNames=metricsServiceOperationByIpDAO.findMetricOperationNames(serviceNames);
      operationNames=removeServiceNamePrefix(operationNames);
      filters.put("String_Node_Str",operationNames);
    }
    metricValuesByOperationName=metricValuesDAO.findMetricValuesByOperation(metricName,beginTime,endTime,serverSide,aggregationPeriod,filters);
    operationNames=filters.get("String_Node_Str");
    for (    String opName : operationNames) {
      List<MetricValue<?>> metricValues=metricValuesByOperationName.get(opName);
      for (int i=0; i < duration / aggregationPeriod; ++i) {
        long startTime=beginTime + TimeUnit.SECONDS.toMillis(i * aggregationPeriod);
        long stopTime=startTime + TimeUnit.SECONDS.toMillis(aggregationPeriod);
        double value=0;
        for (        MetricValue<?> metricValue : metricValues) {
          long time=metricValue.getTimeMiliseconds();
          if (startTime <= time && time < stopTime) {
            value+=(Double)metricValue.getValueForMetric(encodedMetricName);
            break;
          }
        }
        MetricGraphData metricGraphData=new MetricGraphData();
        metricGraphData.setCount(value);
        metricGraphData.setTimeSlot(startTime);
        metricGraphData.setCriteria(null);
        result.add(metricGraphData);
      }
    }
  }
 catch (  ServiceException e) {
    e.printStackTrace();
  }
  return result;
}