Program: 9713
Project: 9713
Buggy source:
public Example getQuestionOptimised(QueryTree<N> lgg,List<QueryTree<N>> negTrees,List<String> knownResources){
  this.lgg=lgg;
  logger.info("String_Node_Str");
  postLGG=getFilteredTree(lgg);
  PostLGG<N> postGen=new PostLGG<N>();
  postGen.simplifyTree(postLGG,negTrees);
  limit=knownResources.size();
  List<GeneralisedQueryTree<N>> queue=getAllowedGeneralisations(new GeneralisedQueryTree<N>(postLGG));
  logger.debug(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>>();
    logger.debug("String_Node_Str");
    tree1=queue.remove(0);
    tmp=tree1;
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + tmp.getChanges());
    }
    queryTree=tmp.getQueryTree();
    boolean coversNegTree=coversNegativeTree(tmp.getQueryTree(),negTrees);
    logger.debug("String_Node_Str" + coversNegTree);
    while (!coversNegTree) {
      gens=getAllowedGeneralisationsSorted(tmp);
      if (gens.isEmpty()) {
        if (logger.isDebugEnabled()) {
          logger.debug("String_Node_Str");
        }
        break;
      }
      tmp=gens.remove(0);
      neededGeneralisations.add(tmp.getQueryTree());
      if (logger.isDebugEnabled()) {
        logger.debug("String_Node_Str" + tmp.getChanges());
      }
      queue.addAll(0,gens);
      logger.debug(getQueueLogInfo(queue));
      coversNegTree=coversNegativeTree(tmp.getQueryTree(),negTrees);
      if (coversNegTree) {
        logger.debug("String_Node_Str");
      }
    }
    int index=neededGeneralisations.size() - 1;
    if (coversNegTree) {
      tree2=neededGeneralisations.get(index--);
    }
 else {
      tree2=tmp.getQueryTree();
    }
    String newResource=getNewResource(tree2,knownResources);
    if (!(newResource == null)) {
      logger.debug("String_Node_Str");
      newResource=findMostSpecificResourceTree(neededGeneralisations,knownResources,0,neededGeneralisations.size() - 1);
      logger.debug("String_Node_Str");
      return new Example(newResource,null,null,null);
    }
 else {
      if (logger.isDebugEnabled()) {
        logger.debug("String_Node_Str");
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public Example getQuestionOptimised(QueryTree<N> lgg,List<QueryTree<N>> negTrees,List<String> knownResources){
  this.lgg=lgg;
  logger.info("String_Node_Str");
  postLGG=getFilteredTree(lgg);
  PostLGG<N> postGen=new PostLGG<N>();
  postGen.simplifyTree(postLGG,negTrees);
  limit=knownResources.size();
  List<GeneralisedQueryTree<N>> queue=getAllowedGeneralisations(new GeneralisedQueryTree<N>(postLGG));
  logger.debug(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>>();
    logger.debug("String_Node_Str");
    tree1=queue.remove(0);
    tmp=tree1;
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + tmp.getChanges());
    }
    queryTree=tmp.getQueryTree();
    boolean coversNegTree=coversNegativeTree(tmp.getQueryTree(),negTrees);
    logger.debug("String_Node_Str" + coversNegTree);
    while (!coversNegTree) {
      gens=getAllowedGeneralisationsSorted(tmp);
      if (gens.isEmpty()) {
        if (logger.isDebugEnabled()) {
          logger.debug("String_Node_Str");
        }
        break;
      }
      tmp=gens.remove(0);
      neededGeneralisations.add(tmp.getQueryTree());
      if (logger.isDebugEnabled()) {
        logger.debug("String_Node_Str" + tmp.getChanges());
      }
      queue.addAll(0,gens);
      logger.debug(getQueueLogInfo(queue));
      coversNegTree=coversNegativeTree(tmp.getQueryTree(),negTrees);
      if (coversNegTree) {
        logger.debug("String_Node_Str");
      }
    }
    int index=neededGeneralisations.size() - 1;
    if (coversNegTree) {
      tree2=neededGeneralisations.get(index--);
    }
 else {
      tree2=tmp.getQueryTree();
    }
    String newResource=getNewResource(tree2,knownResources);
    logger.debug("String_Node_Str" + newResource);
    if (!(newResource == null)) {
      logger.debug("String_Node_Str");
      newResource=findMostSpecificResourceTree(neededGeneralisations,knownResources,0,neededGeneralisations.size() - 1);
      logger.debug("String_Node_Str");
      return new Example(newResource,null,null,null);
    }
 else {
      if (logger.isDebugEnabled()) {
        logger.debug("String_Node_Str");
      }
    }
  }
  return null;
}