Program: 52349
Project: 52349
Buggy source:
/** 
 * Find the groups that match the search query across eperson_group_id or name
 * @param context DSpace context
 * @param query The search string
 * @param offset Inclusive offset 
 * @param limit Maximum number of matches returned
 * @return array of Group objects
 */
public static Group[] search(Context context,String query,int offset,int limit) throws SQLException {
  String params="String_Node_Str" + query.toLowerCase() + "String_Node_Str";
  String dbquery="String_Node_Str";
  if (offset >= 0 && limit > 0) {
    dbquery+="String_Node_Str" + limit + "String_Node_Str"+ offset;
  }
  Integer int_param;
  try {
    int_param=Integer.valueOf(query);
  }
 catch (  NumberFormatException e) {
    int_param=new Integer(-1);
  }
  TableRowIterator rows=DatabaseManager.query(context,dbquery,new Object[]{params,int_param});
  List groupRows=rows.toList();
  Group[] groups=new Group[groupRows.size()];
  for (int i=0; i < groupRows.size(); i++) {
    TableRow row=(TableRow)groupRows.get(i);
    Group fromCache=(Group)context.fromCache(Group.class,row.getIntColumn("String_Node_Str"));
    if (fromCache != null) {
      groups[i]=fromCache;
    }
 else {
      groups[i]=new Group(context,row);
    }
  }
  return groups;
}

Fixed version (ground truth):
/** 
 * Find the groups that match the search query across eperson_group_id or name
 * @param context DSpace context
 * @param query The search string
 * @param offset Inclusive offset 
 * @param limit Maximum number of matches returned
 * @return array of Group objects
 */
public static Group[] search(Context context,String query,int offset,int limit) throws SQLException {
  String params="String_Node_Str" + query.toLowerCase() + "String_Node_Str";
  StringBuffer queryBuf=new StringBuffer();
  queryBuf.append("String_Node_Str");
  if ("String_Node_Str".equals(ConfigurationManager.getProperty("String_Node_Str"))) {
    if (limit > 0 || offset > 0) {
      queryBuf.insert(0,"String_Node_Str");
      queryBuf.append("String_Node_Str");
    }
    if (limit > 0) {
      queryBuf.append("String_Node_Str");
      if (offset > 0)       limit+=offset;
    }
    if (offset > 0) {
      queryBuf.insert(0,"String_Node_Str");
      queryBuf.append("String_Node_Str");
    }
  }
 else {
    if (limit > 0)     queryBuf.append("String_Node_Str");
    if (offset > 0)     queryBuf.append("String_Node_Str");
  }
  String dbquery=queryBuf.toString();
  Integer int_param;
  try {
    int_param=Integer.valueOf(query);
  }
 catch (  NumberFormatException e) {
    int_param=new Integer(-1);
  }
  Object[] paramArr=new Object[]{params,int_param};
  if (limit > 0 && offset > 0)   paramArr=new Object[]{params,int_param,limit,offset};
 else   if (limit > 0)   paramArr=new Object[]{params,int_param,limit};
 else   if (offset > 0)   paramArr=new Object[]{params,int_param,offset};
  TableRowIterator rows=DatabaseManager.query(context,dbquery,paramArr);
  List groupRows=rows.toList();
  Group[] groups=new Group[groupRows.size()];
  for (int i=0; i < groupRows.size(); i++) {
    TableRow row=(TableRow)groupRows.get(i);
    Group fromCache=(Group)context.fromCache(Group.class,row.getIntColumn("String_Node_Str"));
    if (fromCache != null) {
      groups[i]=fromCache;
    }
 else {
      groups[i]=new Group(context,row);
    }
  }
  return groups;
}