Program: 168720
Project: 168720
Buggy source:
private Map<byte[],Statistics> findDefIds(Handle h,String tenantId,String name,Map<String,String> dimensions,DateTime startTime,DateTime endTime){
  List<byte[]> bytes=new ArrayList<>();
  StringBuilder sbWhere=new StringBuilder();
  if (name != null)   sbWhere.append("String_Node_Str");
  if (endTime != null) {
    sbWhere.append("String_Node_Str");
  }
  String sql=String.format(FIND_BY_METRIC_DEF_SQL,MetricQueries.buildJoinClauseFor(dimensions),sbWhere);
  Query<Map<String,Object>> query=h.createQuery(sql).bind("String_Node_Str",tenantId).bind("String_Node_Str",startTime);
  if (name != null) {
    query.bind("String_Node_Str",name);
  }
  if (endTime != null) {
    query.bind("String_Node_Str",new Timestamp(endTime.getMillis()));
  }
  DimensionQueries.bindDimensionsToQuery(query,dimensions);
  List<Map<String,Object>> rows=query.list();
  Map<byte[],Statistics> byteIdMap=new HashMap<>();
  byte[] currentId=null;
  Map<String,String> dims=null;
  for (  Map<String,Object> row : rows) {
    byte[] defId=(byte[])row.get("String_Node_Str");
    String defName=(String)row.get("String_Node_Str");
    String demName=(String)row.get("String_Node_Str");
    String demValue=(String)row.get("String_Node_Str");
    if (defId == null || !Arrays.equals(currentId,defId)) {
      currentId=defId;
      dims=new HashMap<>();
      dims.put(demName,demValue);
      Statistics statistics=new Statistics();
      statistics.setName(defName);
      statistics.setDimensions(dims);
      byteIdMap.put(currentId,statistics);
    }
 else     dims.put(demName,demValue);
  }
  bytes.add(currentId);
  return byteIdMap;
}

Fixed version (ground truth):
private Map<byte[],Statistics> findDefIds(Handle h,String tenantId,String name,Map<String,String> dimensions,DateTime startTime,DateTime endTime){
  List<byte[]> bytes=new ArrayList<>();
  StringBuilder sbWhere=new StringBuilder();
  if (name != null)   sbWhere.append("String_Node_Str");
  String sql=String.format(FIND_BY_METRIC_DEF_SQL,MetricQueries.buildJoinClauseFor(dimensions),sbWhere);
  Query<Map<String,Object>> query=h.createQuery(sql).bind("String_Node_Str",tenantId).bind("String_Node_Str",startTime);
  if (name != null) {
    query.bind("String_Node_Str",name);
  }
  if (endTime != null) {
    query.bind("String_Node_Str",new Timestamp(endTime.getMillis()));
  }
  DimensionQueries.bindDimensionsToQuery(query,dimensions);
  List<Map<String,Object>> rows=query.list();
  Map<byte[],Statistics> byteIdMap=new HashMap<>();
  byte[] currentId=null;
  Map<String,String> dims=null;
  for (  Map<String,Object> row : rows) {
    byte[] defId=(byte[])row.get("String_Node_Str");
    String defName=(String)row.get("String_Node_Str");
    String demName=(String)row.get("String_Node_Str");
    String demValue=(String)row.get("String_Node_Str");
    if (defId == null || !Arrays.equals(currentId,defId)) {
      currentId=defId;
      dims=new HashMap<>();
      dims.put(demName,demValue);
      Statistics statistics=new Statistics();
      statistics.setName(defName);
      statistics.setDimensions(dims);
      byteIdMap.put(currentId,statistics);
    }
 else     dims.put(demName,demValue);
  }
  bytes.add(currentId);
  return byteIdMap;
}