Program: 168718
Project: 168718
Buggy source:
@Override public List<MetricDefinition> find(String tenantId,String name,Map<String,String> dimensions) throws Exception {
  String dimsPart=Utils.WhereClauseBuilder.buildDimsPart(dimensions);
  String query=String.format("String_Node_Str",Utils.SQLSanitizer.sanitize(tenantId),dimsPart);
  logger.debug("String_Node_Str",query);
  List<Serie> result=this.influxDB.Query(this.config.influxDB.getName(),query,TimeUnit.SECONDS);
  List<MetricDefinition> metricDefinitionList=new ArrayList<>();
  for (  Serie serie : result) {
    MetricDefinition metricDefinition=new MetricDefinition();
    metricDefinition.name=serie.getName();
    metricDefinition.setDimensions(dimensions == null ? new HashMap<String,String>() : dimensions);
    metricDefinitionList.add(metricDefinition);
  }
  return metricDefinitionList;
}

Fixed version (ground truth):
@Override public List<MetricDefinition> find(String tenantId,String name,Map<String,String> dimensions) throws Exception {
  String namePart=name == null ? "String_Node_Str" : Utils.SQLSanitizer.sanitize(name);
  List<MetricDefinition> metricDefinitionList=new ArrayList<>();
  if (dimensions == null || dimensions.isEmpty()) {
    String query=String.format("String_Node_Str",namePart);
    logger.debug("String_Node_Str",query);
    List<Serie> result=this.influxDB.Query(this.config.influxDB.getName(),query,TimeUnit.SECONDS);
    Map<TreeSet,List<String>> columnsToNamesMap=new HashMap<TreeSet,List<String>>();
    for (    Serie serie : result) {
      TreeSet<String> columnsSet=new TreeSet<String>();
      for (      String columnName : serie.getColumns()) {
        if (columnName.equalsIgnoreCase("String_Node_Str")) {
          continue;
        }
 else         if (columnName.equalsIgnoreCase("String_Node_Str")) {
          continue;
        }
 else         if (columnName.equalsIgnoreCase("String_Node_Str")) {
          continue;
        }
 else {
          columnsSet.add(columnName);
        }
      }
      if (columnsToNamesMap.containsKey(columnsSet)) {
        columnsToNamesMap.get(columnsSet).add(serie.getName());
      }
 else {
        List<String> nameList=new LinkedList<String>();
        nameList.add(serie.getName());
        columnsToNamesMap.put(columnsSet,nameList);
      }
    }
    for (    TreeSet columnsSet : columnsToNamesMap.keySet()) {
      List nameList=columnsToNamesMap.get(columnsSet);
      String groupByPart="String_Node_Str";
      if (columnsSet.size() > 0) {
        groupByPart="String_Node_Str" + Joiner.on("String_Node_Str").join(columnsSet);
      }
      String namesPart="String_Node_Str" + Joiner.on("String_Node_Str").join(nameList) + "String_Node_Str";
      String query2=String.format("String_Node_Str",namesPart,groupByPart);
      logger.debug("String_Node_Str",query2);
      List<Serie> result2=this.influxDB.Query(this.config.influxDB.getName(),query2,TimeUnit.SECONDS);
      for (      Serie serie : result2) {
        for (        Object[] pointsArry : serie.getPoints()) {
          MetricDefinition metricDefinition=new MetricDefinition();
          metricDefinition.name=serie.getName();
          Map<String,String> dimMap=new HashMap<String,String>();
          for (int i=2; i < serie.getColumns().length; ++i) {
            Object dimValue=pointsArry[i];
            if (dimValue != null) {
              dimMap.put((String)serie.getColumns()[i],(String)dimValue);
            }
          }
          metricDefinition.setDimensions(dimMap);
          metricDefinitionList.add(metricDefinition);
        }
      }
    }
  }
 else {
    String dimsPart=Utils.WhereClauseBuilder.buildDimsPart(dimensions);
    String query=String.format("String_Node_Str" + "String_Node_Str",namePart,Utils.SQLSanitizer.sanitize(tenantId),dimsPart);
    logger.debug("String_Node_Str",query);
    List<Serie> result=this.influxDB.Query(this.config.influxDB.getName(),query,TimeUnit.SECONDS);
    for (    Serie serie : result) {
      MetricDefinition metricDefinition=new MetricDefinition();
      metricDefinition.name=serie.getName();
      metricDefinition.setDimensions(dimensions == null ? new HashMap<String,String>() : dimensions);
      metricDefinitionList.add(metricDefinition);
    }
  }
  return metricDefinitionList;
}