Program: 9472
Project: 9472
Buggy source:
private String computeQuestionBetterPerformance(QueryTree<N> lgg,List<QueryTree<N>> negTrees,List<String> knownResources) throws TimeOutException {
  startTime=System.currentTimeMillis();
  this.lgg=lgg;
  this.negTrees=negTrees;
  if (userAnsweredWithNo()) {
    noSequences.add(lastSequence);
  }
  negExamplesCount=negTrees.size();
  determiningNodeIds=getDeterminingNodeIds(lgg,negTrees);
  logger.debug("String_Node_Str");
  postLGG=getFilteredTree(lgg);
  PostLGG<N> postGen=new PostLGG<N>((SPARQLEndpointEx)endpoint);
  postGen.simplifyTree(postLGG,negTrees);
  if (logger.isDebugEnabled()) {
    String treeString;
    if (endpoint instanceof SPARQLEndpointEx) {
      treeString=TreeHelper.getAbbreviatedTreeRepresentation(postLGG,((SPARQLEndpointEx)endpoint).getBaseURI(),((SPARQLEndpointEx)endpoint).getPrefixes());
    }
 else {
      treeString=postLGG.getStringRepresentation();
    }
    logger.debug("String_Node_Str" + treeString);
    logger.debug("String_Node_Str" + postLGG.toSPARQLQueryString());
    logger.debug("String_Node_Str" + getAllResources(postLGG.toSPARQLQueryString()).size());
  }
  limit=knownResources.size();
  List<GeneralisedQueryTree<N>> queue=null;
  if (generalizeSortedByNegatives) {
    queue=getAllowedGeneralisationsSortedByMatrix(new GeneralisedQueryTree<N>(postLGG),negTrees);
  }
 else {
    queue=getAllowedGeneralisationsSorted2(new GeneralisedQueryTree<N>(postLGG));
  }
  logger.debug(getQueueLogInfo(queue));
  GeneralisedQueryTree<N> tree1;
  GeneralisedQueryTree<N> tree2;
  GeneralisedQueryTree<N> tmp;
  List<GeneralisedQueryTree<N>> gens;
  List<GeneralisedQueryTree<N>> neededGeneralisations;
  while (!queue.isEmpty()) {
    neededGeneralisations=new ArrayList<GeneralisedQueryTree<N>>();
    logger.debug("String_Node_Str");
    tree1=getGeneralisedQueryTreeNotContainingNoSequence(queue);
    tmp=tree1;
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + tmp.getChanges());
    }
    boolean coversNegTree=coversNegativeTree(tmp.getQueryTree(),negTrees);
    neededGeneralisations.add(tmp);
    logger.debug("String_Node_Str" + coversNegTree);
    while (!coversNegTree) {
      if (generalizeSortedByNegatives) {
        gens=getAllowedGeneralisationsSortedByMatrix(tmp,negTrees);
      }
 else {
        gens=getAllowedGeneralisationsSorted2(tmp);
      }
      if (gens.isEmpty()) {
        if (logger.isDebugEnabled()) {
          logger.debug("String_Node_Str");
        }
        break;
      }
      tmp=getGeneralisedQueryTreeNotContainingNoSequence(gens);
      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" + tmp.getChanges());
      }
 else {
        neededGeneralisations.add(tmp);
      }
    }
    int index=neededGeneralisations.size() - 1;
    if (coversNegTree) {
      if (index == -1) {
        tree2=tmp;
      }
      tree2=neededGeneralisations.get(index--);
    }
 else {
      tree2=tmp;
    }
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + tree2.getQueryTree().getStringRepresentation());
    }
    String newResource=getNewResource2(fSparql(lgg,tree2.getChanges()),knownResources);
    if (isTerminationCriteriaReached()) {
      throw new TimeOutException(maxExecutionTimeInSeconds);
    }
    logger.debug("String_Node_Str" + newResource);
    if (!(newResource == null)) {
      logger.debug("String_Node_Str");
      List<QueryTreeChange> firstChanges=new ArrayList<QueryTreeChange>(neededGeneralisations.get(0).getChanges());
      while (firstChanges.size() > 1) {
        firstChanges.remove(firstChanges.size() - 1);
        neededGeneralisations.add(0,new GeneralisedQueryTree<N>(getTreeByChanges(lgg,firstChanges),firstChanges));
        firstChanges=new ArrayList<QueryTreeChange>(firstChanges);
      }
      newResource=findMostSpecificResourceTree2(neededGeneralisations,knownResources,0,neededGeneralisations.size() - 1);
      logger.debug("String_Node_Str");
      return newResource;
    }
 else {
      if (logger.isDebugEnabled()) {
        logger.debug("String_Node_Str");
      }
    }
  }
  return null;
}

Fixed version (ground truth):
private String computeQuestionBetterPerformance(QueryTree<N> lgg,List<QueryTree<N>> negTrees,List<String> knownResources) throws TimeOutException {
  startTime=System.currentTimeMillis();
  this.lgg=lgg;
  this.negTrees=negTrees;
  if (userAnsweredWithNo()) {
    noSequences.add(lastSequence);
  }
  negExamplesCount=negTrees.size();
  determiningNodeIds=getDeterminingNodeIds(lgg,negTrees);
  logger.debug("String_Node_Str");
  postLGG=getFilteredTree(lgg);
  PostLGG<N> postGen;
  if (endpoint != null) {
    postGen=new PostLGG<N>((SPARQLEndpointEx)endpoint);
  }
 else {
    postGen=new PostLGG<N>();
  }
  postGen.simplifyTree(postLGG,negTrees);
  if (logger.isDebugEnabled()) {
    String treeString;
    if (endpoint instanceof SPARQLEndpointEx) {
      treeString=TreeHelper.getAbbreviatedTreeRepresentation(postLGG,((SPARQLEndpointEx)endpoint).getBaseURI(),((SPARQLEndpointEx)endpoint).getPrefixes());
    }
 else {
      treeString=postLGG.getStringRepresentation();
    }
    logger.debug("String_Node_Str" + treeString);
    logger.debug("String_Node_Str" + postLGG.toSPARQLQueryString());
    logger.debug("String_Node_Str" + getAllResources(postLGG.toSPARQLQueryString()).size());
  }
  limit=knownResources.size();
  List<GeneralisedQueryTree<N>> queue=null;
  if (generalizeSortedByNegatives) {
    queue=getAllowedGeneralisationsSortedByMatrix(new GeneralisedQueryTree<N>(postLGG),negTrees);
  }
 else {
    queue=getAllowedGeneralisationsSorted2(new GeneralisedQueryTree<N>(postLGG));
  }
  logger.debug(getQueueLogInfo(queue));
  GeneralisedQueryTree<N> tree1;
  GeneralisedQueryTree<N> tree2;
  GeneralisedQueryTree<N> tmp;
  List<GeneralisedQueryTree<N>> gens;
  List<GeneralisedQueryTree<N>> neededGeneralisations;
  while (!queue.isEmpty()) {
    neededGeneralisations=new ArrayList<GeneralisedQueryTree<N>>();
    logger.debug("String_Node_Str");
    tree1=getGeneralisedQueryTreeNotContainingNoSequence(queue);
    tmp=tree1;
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + tmp.getChanges());
    }
    boolean coversNegTree=coversNegativeTree(tmp.getQueryTree(),negTrees);
    neededGeneralisations.add(tmp);
    logger.debug("String_Node_Str" + coversNegTree);
    while (!coversNegTree) {
      if (generalizeSortedByNegatives) {
        gens=getAllowedGeneralisationsSortedByMatrix(tmp,negTrees);
      }
 else {
        gens=getAllowedGeneralisationsSorted2(tmp);
      }
      if (gens.isEmpty()) {
        if (logger.isDebugEnabled()) {
          logger.debug("String_Node_Str");
        }
        break;
      }
      tmp=getGeneralisedQueryTreeNotContainingNoSequence(gens);
      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" + tmp.getChanges());
      }
 else {
        neededGeneralisations.add(tmp);
      }
    }
    int index=neededGeneralisations.size() - 1;
    if (coversNegTree) {
      if (index == -1) {
        tree2=tmp;
      }
      tree2=neededGeneralisations.get(index--);
    }
 else {
      tree2=tmp;
    }
    if (logger.isDebugEnabled()) {
      logger.debug("String_Node_Str" + tree2.getQueryTree().getStringRepresentation());
    }
    String newResource=getNewResource2(fSparql(lgg,tree2.getChanges()),knownResources);
    if (isTerminationCriteriaReached()) {
      throw new TimeOutException(maxExecutionTimeInSeconds);
    }
    logger.debug("String_Node_Str" + newResource);
    if (!(newResource == null)) {
      logger.debug("String_Node_Str");
      List<QueryTreeChange> firstChanges=new ArrayList<QueryTreeChange>(neededGeneralisations.get(0).getChanges());
      while (firstChanges.size() > 1) {
        firstChanges.remove(firstChanges.size() - 1);
        neededGeneralisations.add(0,new GeneralisedQueryTree<N>(getTreeByChanges(lgg,firstChanges),firstChanges));
        firstChanges=new ArrayList<QueryTreeChange>(firstChanges);
      }
      newResource=findMostSpecificResourceTree2(neededGeneralisations,knownResources,0,neededGeneralisations.size() - 1);
      logger.debug("String_Node_Str");
      return newResource;
    }
 else {
      if (logger.isDebugEnabled()) {
        logger.debug("String_Node_Str");
      }
    }
  }
  return null;
}