Program: 73668
Project: 73668
Buggy source:
/** 
 * Execute the given task to fetch the first level parents for the given  model. First level parents are models that are immediate parents for the given  model.
 * @param model Model for which the first level parents list needs to be fetched.
 * @return List of models that are the first-level parents of the given model.
 * @throws DBExecutionException If thrown while fetching the parents list from the database.
 */
public List<XMLDBModel> executeGetFirstLevelParents(GetFirstLevelParentsTask task) throws DBExecutionException {
  String references=null;
  ArrayList<XMLDBModel> parentsList=new ArrayList<XMLDBModel>();
  XMLDBModel model=task.getModel();
  try {
    XmlQueryContext xmlContext=_xmlManager.createQueryContext();
    String query="String_Node_Str" + "String_Node_Str" + "String_Node_Str" + model.getModelName() + "String_Node_Str";
    XmlQueryExpression queryExpression=_xmlManager.prepare(query,xmlContext);
    XmlResults results=queryExpression.execute(xmlContext);
    if (results != null && results.size() > 0) {
      XmlValue xmlValue=results.next();
      references="String_Node_Str" + xmlValue.asString() + "String_Node_Str";
      Node entitiesNode=Utilities.parseXML(references);
      NodeList entityList=entitiesNode.getChildNodes();
      for (int i=0; i < entityList.getLength(); i++) {
        Node entity=entityList.item(i);
        String parentName=Utilities.getValueForAttribute(entity,XMLDBModel.DB_MODEL_NAME);
        String parentId=Utilities.getValueForAttribute(entity,XMLDBModel.DB_MODEL_ID_ATTR);
        parentsList.add(new XMLDBModel(parentName,parentId));
      }
    }
  }
 catch (  XmlException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
catch (  XMLDBModelParsingException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
  return parentsList;
}

Fixed version (ground truth):
/** 
 * Execute the given task to fetch the first level parents for the given  model. First level parents are models that are immediate parents for the given  model.
 * @param model Model for which the first level parents list needs to be fetched.
 * @return List of models that are the first-level parents of the given model.
 * @throws DBExecutionException If thrown while fetching the parents list from the database.
 */
public List<XMLDBModel> executeGetFirstLevelParents(GetFirstLevelParentsTask task) throws DBExecutionException {
  String references=null;
  ArrayList<XMLDBModel> parentsList=new ArrayList<XMLDBModel>();
  HashSet alreadyFetchedParents=new HashSet();
  XMLDBModel model=task.getModel();
  try {
    XmlQueryContext xmlContext=_xmlManager.createQueryContext();
    String query="String_Node_Str" + _params.getContainerName() + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ model.getModelName()+ "String_Node_Str";
    XmlQueryExpression queryExpression=_xmlManager.prepare(query,xmlContext);
    XmlResults results=queryExpression.execute(xmlContext);
    if (results != null && results.size() > 0) {
      XmlValue xmlValue=results.next();
      references="String_Node_Str" + xmlValue.asString() + "String_Node_Str";
      Node entitiesNode=Utilities.parseXML(references);
      NodeList entityList=entitiesNode.getChildNodes();
      for (int i=0; i < entityList.getLength(); i++) {
        Node entity=entityList.item(i);
        String parentName=Utilities.getValueForAttribute(entity,XMLDBModel.DB_MODEL_NAME);
        String parentId=Utilities.getValueForAttribute(entity,XMLDBModel.DB_MODEL_ID_ATTR);
        if (!alreadyFetchedParents.contains(parentName)) {
          parentsList.add(new XMLDBModel(parentName,parentId));
          alreadyFetchedParents.add(parentName);
        }
      }
    }
  }
 catch (  XmlException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
catch (  XMLDBModelParsingException e) {
    throw new DBExecutionException("String_Node_Str" + e.getMessage(),e);
  }
  return parentsList;
}