Program: 105251
Project: 105251
Buggy source:
@Override public List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId,String[] tags){
  List<StoragePoolVO> storagePools=null;
  if (tags == null || tags.length == 0) {
    QueryBuilder<StoragePoolVO> sc=QueryBuilder.create(StoragePoolVO.class);
    sc.and(sc.entity().getDataCenterId(),Op.EQ,dcId);
    sc.and(sc.entity().getStatus(),Op.EQ,Status.Up);
    sc.and(sc.entity().getScope(),Op.EQ,ScopeType.ZONE);
    return sc.list();
  }
 else {
    Map<String,String> details=tagsToDetails(tags);
    StringBuilder sql=new StringBuilder(ZoneWideDetailsSqlPrefix);
    for (    Map.Entry<String,String> detail : details.entrySet()) {
      sql.append("String_Node_Str").append(detail.getKey()).append("String_Node_Str").append(detail.getValue()).append("String_Node_Str");
    }
    sql.delete(sql.length() - 4,sql.length());
    sql.append(ZoneWideDetailsSqlSuffix);
    TransactionLegacy txn=TransactionLegacy.currentTxn();
    try (PreparedStatement pstmt=txn.prepareStatement(sql.toString())){
      List<StoragePoolVO> pools=new ArrayList<StoragePoolVO>();
      if (pstmt != null) {
        int i=1;
        pstmt.setLong(i++,dcId);
        pstmt.setString(i++,ScopeType.ZONE.toString());
        pstmt.setInt(i++,details.size());
        try (ResultSet rs=pstmt.executeQuery()){
          while (rs.next()) {
            pools.add(toEntityBean(rs,false));
          }
        }
 catch (        SQLException e) {
          throw new CloudRuntimeException("String_Node_Str" + e.getMessage(),e);
        }
      }
      return pools;
    }
 catch (    SQLException e) {
      throw new CloudRuntimeException("String_Node_Str" + e.getMessage(),e);
    }
  }
}

Fixed version (ground truth):
@Override public List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId,String[] tags){
  List<StoragePoolVO> storagePools=null;
  if (tags == null || tags.length == 0) {
    QueryBuilder<StoragePoolVO> sc=QueryBuilder.create(StoragePoolVO.class);
    sc.and(sc.entity().getDataCenterId(),Op.EQ,dcId);
    sc.and(sc.entity().getStatus(),Op.EQ,Status.Up);
    sc.and(sc.entity().getScope(),Op.EQ,ScopeType.ZONE);
    return sc.list();
  }
 else {
    Map<String,String> details=tagsToDetails(tags);
    StringBuilder sql=new StringBuilder(ZoneWideDetailsSqlPrefix);
    for (int i=0; i < details.size(); i++) {
      sql.append("String_Node_Str");
    }
    sql.delete(sql.length() - 4,sql.length());
    sql.append(ZoneWideDetailsSqlSuffix);
    TransactionLegacy txn=TransactionLegacy.currentTxn();
    try (PreparedStatement pstmt=txn.prepareStatement(sql.toString())){
      int i=0;
      for (      Map.Entry<String,String> detail : details.entrySet()) {
        pstmt.setString(++i,detail.getKey());
        pstmt.setString(++i,detail.getValue());
      }
      List<StoragePoolVO> pools=new ArrayList<StoragePoolVO>();
      if (pstmt != null) {
        i=1;
        pstmt.setLong(i++,dcId);
        pstmt.setString(i++,ScopeType.ZONE.toString());
        pstmt.setInt(i++,details.size());
        try (ResultSet rs=pstmt.executeQuery()){
          while (rs.next()) {
            pools.add(toEntityBean(rs,false));
          }
        }
 catch (        SQLException e) {
          throw new CloudRuntimeException("String_Node_Str" + e.getMessage(),e);
        }
      }
      return pools;
    }
 catch (    SQLException e) {
      throw new CloudRuntimeException("String_Node_Str" + e.getMessage(),e);
    }
  }
}