Program: 18531
Project: 18531
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public List<MetricGraphData> getErrorGraph(final String serviceName,final String operationName,final String consumerName,final String errorId,final String errorCategory,final String errorSeverity,final MetricCriteria metricCriteria){
  List<MetricGraphData> result=new ArrayList<MetricGraphData>();
  int aggregationPeriod=metricCriteria.getAggregationPeriod();
  long beginTime=metricCriteria.getFirstStartTime();
  long duration=metricCriteria.getDuration();
  long endTime=beginTime + TimeUnit.SECONDS.toMillis(duration);
  boolean serverSide=MonitoringSystem.COLLECTION_LOCATION_SERVER.equals(metricCriteria.getRoleType());
  Map<String,List<String>> filters=new HashMap<String,List<String>>();
  if (serviceName != null && !"String_Node_Str".equals(serviceName)) {
    filters.put(ResourceEntity.SERVICE.value(),Collections.singletonList(serviceName));
  }
  if (operationName != null && !"String_Node_Str".equals(operationName)) {
    filters.put(ResourceEntity.OPERATION.value(),Collections.singletonList(operationName));
  }
  if (consumerName != null && !"String_Node_Str".equals(consumerName)) {
    filters.put(ResourceEntity.CONSUMER.value(),Collections.singletonList(consumerName));
  }
  List<Map<String,Object>> queryResult=new ArrayList<Map<String,Object>>();
  if (errorCategory != null) {
    final String filter=(errorCategory == null ? null : ErrorCategory.fromValue(errorCategory).name());
    queryResult=metricsErrorsByCategoryDAO.findErrorValuesByFilter(beginTime,endTime,serverSide,aggregationPeriod,null,filter,filters);
  }
 else   if (errorSeverity != null) {
    final String filter=(errorSeverity == null ? null : ErrorSeverity.fromValue(errorSeverity).name());
    queryResult=metricsErrorsBySeverityDAO.findErrorValuesByFilter(beginTime,endTime,serverSide,aggregationPeriod,null,filter,filters);
  }
  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 (    Map<String,Object> row : queryResult) {
      long time=(Long)row.get("String_Node_Str");
      if (startTime <= time && time < stopTime) {
        value+=1;
      }
    }
    MetricGraphData metricGraphData=new MetricGraphData();
    metricGraphData.setCount(value);
    metricGraphData.setTimeSlot(startTime);
    metricGraphData.setCriteria(null);
    result.add(metricGraphData);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public List<MetricGraphData> getErrorGraph(final String serviceName,final String operationName,final String consumerName,final String errorId,final String errorCategory,final String errorSeverity,final MetricCriteria metricCriteria){
  List<MetricGraphData> result=new ArrayList<MetricGraphData>();
  int aggregationPeriod=metricCriteria.getAggregationPeriod();
  long beginTime=metricCriteria.getFirstStartTime();
  long duration=metricCriteria.getDuration();
  long endTime=beginTime + TimeUnit.SECONDS.toMillis(duration);
  boolean serverSide=MonitoringSystem.COLLECTION_LOCATION_SERVER.equals(metricCriteria.getRoleType());
  Map<String,List<String>> filters=new HashMap<String,List<String>>();
  if (serviceName != null && !"String_Node_Str".equals(serviceName)) {
    filters.put(ResourceEntity.SERVICE.value(),Collections.singletonList(serviceName));
  }
  if (operationName != null && !"String_Node_Str".equals(operationName)) {
    filters.put(ResourceEntity.OPERATION.value(),Collections.singletonList(operationName));
  }
  if (consumerName != null && !"String_Node_Str".equals(consumerName)) {
    filters.put(ResourceEntity.CONSUMER.value(),Collections.singletonList(consumerName));
  }
  List<Map<String,Object>> queryResult=new ArrayList<Map<String,Object>>();
  if (errorCategory != null) {
    final String filter=(errorCategory == null ? null : ErrorCategory.fromValue(errorCategory).name());
    queryResult=metricsErrorsByCategoryDAO.findErrorValuesByFilter(beginTime,endTime,serverSide,aggregationPeriod,null,filter,filters);
  }
 else   if (errorSeverity != null) {
    final String filter=(errorSeverity == null ? null : ErrorSeverity.fromValue(errorSeverity).name());
    queryResult=metricsErrorsBySeverityDAO.findErrorValuesByFilter(beginTime,endTime,serverSide,aggregationPeriod,null,filter,filters);
  }
  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 (    Map<String,Object> row : queryResult) {
      long time=(Long)row.get("String_Node_Str");
      if (startTime <= time && time < stopTime) {
        value+=(Long)row.get("String_Node_Str");
      }
    }
    MetricGraphData metricGraphData=new MetricGraphData();
    metricGraphData.setCount(value);
    metricGraphData.setTimeSlot(startTime);
    metricGraphData.setCriteria(null);
    result.add(metricGraphData);
  }
  return result;
}