Program: 9718
Project: 9718
Buggy source:
public Example getQuestionOptimised(QueryTree<N> lgg,List<QueryTree<N>> negTrees,List<String> knownResources){
  lgg=getFilteredTree(lgg);
  logger.info(lgg.getStringRepresentation());
  limit=knownResources.size();
  List<GeneralisedQueryTree<N>> queue=getAllowedGeneralisations(new GeneralisedQueryTree<N>(lgg));
  logger.info(getQueueLogInfo(queue));
  GeneralisedQueryTree<N> tree1;
  QueryTree<N> tree2;
  GeneralisedQueryTree<N> tmp;
  QueryTree<N> queryTree;
  List<GeneralisedQueryTree<N>> gens;
  List<QueryTree<N>> neededGeneralisations;
  while (!queue.isEmpty()) {
    neededGeneralisations=new ArrayList<QueryTree<N>>();
    tree1=queue.remove(0);
    tmp=tree1;
    if (logger.isInfoEnabled()) {
      logger.info("String_Node_Str" + tmp.getChanges());
    }
    queryTree=tmp.getQueryTree();
    boolean coversNegTree=coversNegativeTree(tmp.getQueryTree(),negTrees);
    logger.info("String_Node_Str" + coversNegTree);
    while (!coversNegTree) {
      gens=getAllowedGeneralisationsSorted(tmp);
      if (gens.isEmpty()) {
        if (logger.isInfoEnabled()) {
          logger.info("String_Node_Str");
        }
        break;
      }
      tmp=gens.remove(0);
      neededGeneralisations.add(tmp.getQueryTree());
      if (logger.isInfoEnabled()) {
        logger.info("String_Node_Str" + tmp.getChanges());
      }
      queue.addAll(0,gens);
      logger.info(getQueueLogInfo(queue));
      coversNegTree=coversNegativeTree(tmp.getQueryTree(),negTrees);
      if (coversNegTree) {
        logger.info("String_Node_Str");
      }
    }
    int index=neededGeneralisations.size() - 1;
    if (coversNegTree) {
      tree2=neededGeneralisations.get(index--);
    }
 else {
      tree2=tmp.getQueryTree();
    }
    SortedSet<String> foundResources=getResources(tree2);
    foundResources.removeAll(knownResources);
    Example example;
    if (!foundResources.isEmpty()) {
      logger.info("String_Node_Str");
      int i=findMostSpecificResourceTree(neededGeneralisations,knownResources,0,neededGeneralisations.size() - 1);
      foundResources=getResources(neededGeneralisations.get(i));
      logger.info("String_Node_Str");
      return new Example(foundResources.first(),null,null,null);
    }
 else {
      if (logger.isInfoEnabled()) {
        logger.info("String_Node_Str");
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public Example getQuestionOptimised(QueryTree<N> lgg,List<QueryTree<N>> negTrees,List<String> knownResources){
  lgg=getFilteredTree(lgg);
  logger.info(lgg.getStringRepresentation());
  limit=knownResources.size();
  List<GeneralisedQueryTree<N>> queue=getAllowedGeneralisations(new GeneralisedQueryTree<N>(lgg));
  logger.info(getQueueLogInfo(queue));
  GeneralisedQueryTree<N> tree1;
  QueryTree<N> tree2;
  GeneralisedQueryTree<N> tmp;
  QueryTree<N> queryTree;
  List<GeneralisedQueryTree<N>> gens;
  List<QueryTree<N>> neededGeneralisations;
  while (!queue.isEmpty()) {
    neededGeneralisations=new ArrayList<QueryTree<N>>();
    tree1=queue.remove(0);
    tmp=tree1;
    if (logger.isInfoEnabled()) {
      logger.info("String_Node_Str" + tmp.getChanges());
    }
    queryTree=tmp.getQueryTree();
    boolean coversNegTree=coversNegativeTree(tmp.getQueryTree(),negTrees);
    logger.info("String_Node_Str" + coversNegTree);
    while (!coversNegTree) {
      gens=getAllowedGeneralisationsSorted(tmp);
      if (gens.isEmpty()) {
        if (logger.isInfoEnabled()) {
          logger.info("String_Node_Str");
        }
        break;
      }
      tmp=gens.remove(0);
      neededGeneralisations.add(tmp.getQueryTree());
      if (logger.isInfoEnabled()) {
        logger.info("String_Node_Str" + tmp.getChanges());
      }
      queue.addAll(0,gens);
      logger.info(getQueueLogInfo(queue));
      coversNegTree=coversNegativeTree(tmp.getQueryTree(),negTrees);
      if (coversNegTree) {
        logger.info("String_Node_Str");
      }
    }
    int index=neededGeneralisations.size() - 1;
    if (coversNegTree) {
      tree2=neededGeneralisations.get(index--);
    }
 else {
      tree2=tmp.getQueryTree();
    }
    SortedSet<String> foundResources=getResources(tree2);
    foundResources.removeAll(knownResources);
    Example example;
    if (!foundResources.isEmpty()) {
      logger.info("String_Node_Str");
      int i=findMostSpecificResourceTree(neededGeneralisations,knownResources,0,neededGeneralisations.size() - 1);
      foundResources=getResources(neededGeneralisations.get(i));
      foundResources.removeAll(knownResources);
      logger.info("String_Node_Str");
      return new Example(foundResources.first(),null,null,null);
    }
 else {
      if (logger.isInfoEnabled()) {
        logger.info("String_Node_Str");
      }
    }
  }
  return null;
}