Program: 18534
Project: 18534
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 {
    List<String> serviceNames=filters.get("String_Node_Str");
    List<String> operationNames=filters.get("String_Node_Str");
    if (operationNames == null || operationNames.isEmpty()) {
      operationNames=metricsServiceOperationByIpDAO.findMetricOperationNames(serviceNames);
      operationNames=removeServiceNamePrefix(operationNames);
      filters.put("String_Node_Str",operationNames);
    }
    for (    String serviceName : serviceNames) {
      List<String> ipAddressList=this.ipPerDayAndServiceNameDAO.findByDateAndServiceName(System.currentTimeMillis(),serviceName);
      metricValuesByOperationName=metricValuesDAO.findMetricValuesByOperation(ipAddressList,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;
}

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());
  boolean totalizeResultsPerService=false;
  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<?>>> metricValuesMap;
  try {
    List<String> serviceNames=filters.get("String_Node_Str");
    List<String> operationNames=filters.get("String_Node_Str");
    List<String> consumerNames=filters.get("String_Node_Str");
    if (operationNames == null || operationNames.isEmpty()) {
      operationNames=metricsServiceOperationByIpDAO.findMetricOperationNames(serviceNames);
      operationNames=removeServiceNamePrefix(operationNames);
      filters.put("String_Node_Str",operationNames);
      totalizeResultsPerService=true;
    }
    if (consumerNames != null && !consumerNames.isEmpty()) {
      for (      String serviceName : serviceNames) {
        List<String> ipAddressList=this.ipPerDayAndServiceNameDAO.findByDateAndServiceName(System.currentTimeMillis(),serviceName);
        metricValuesMap=metricValuesDAO.findMetricValuesByConsumer(ipAddressList,metricName,beginTime,endTime,serverSide,aggregationPeriod,serviceName,operationNames,consumerNames);
        for (        String consumerName : consumerNames) {
          List<MetricValue<?>> metricValues=metricValuesMap.get(consumerName);
          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);
          }
        }
      }
    }
 else {
      for (      String serviceName : serviceNames) {
        List<String> ipAddressList=this.ipPerDayAndServiceNameDAO.findByDateAndServiceName(System.currentTimeMillis(),serviceName);
        metricValuesMap=metricValuesDAO.findMetricValuesByOperation(ipAddressList,metricName,beginTime,endTime,serverSide,aggregationPeriod,filters);
        operationNames=filters.get("String_Node_Str");
        for (        String opName : operationNames) {
          List<MetricValue<?>> metricValues=metricValuesMap.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;
}