Program: 9670
Project: 9670
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.info("String_Node_Str");
  postLGG=getFilteredTree(lgg);
  PostLGG<N> postGen=new PostLGG<N>((SPARQLEndpointEx)endpoint);
  postGen.simplifyTree(postLGG,negTrees);
  logger.info("String_Node_Str" + TreeHelper.getAbbreviatedTreeRepresentation(postLGG,endpoint.getBaseURI(),endpoint.getPrefixes()));
  logger.info("String_Node_Str" + postLGG.toSPARQLQueryString());
  logger.info("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=getAllowedGeneralisationsSorted(new GeneralisedQueryTree<N>(postLGG));
  }
  logger.debug(getQueueLogInfo(queue));
  GeneralisedQueryTree<N> tree1;
  QueryTree<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=getAllowedGeneralisationsSorted(tmp);
      }
      if (gens.isEmpty()) {
        if (logger.isDebugEnabled()) {
          logger.debug("String_Node_Str");
        }
        break;
      }
      tmp=getGeneralisedQueryTreeNotContainingNoSequence(gens);
      neededGeneralisations.add(tmp);
      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) {
      if (index == -1) {
        tree2=tmp.getQueryTree();
      }
      tree2=neededGeneralisations.get(index--).getQueryTree();
    }
 else {
      tree2=tmp.getQueryTree();
    }
    String newResource=getNewResource2(fSparql(lgg,neededGeneralisations.get(index).getChanges()),knownResources);
    if (isTerminationCriteriaReached()) {
      throw new TimeOutException(maxExecutionTimeInSeconds);
    }
    fSparql(postLGG,tmp.getChanges());
    logger.debug("String_Node_Str" + newResource);
    if (!(newResource == null)) {
      logger.debug("String_Node_Str");
      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.info("String_Node_Str");
  postLGG=getFilteredTree(lgg);
  PostLGG<N> postGen=new PostLGG<N>((SPARQLEndpointEx)endpoint);
  postGen.simplifyTree(postLGG,negTrees);
  logger.info("String_Node_Str" + TreeHelper.getAbbreviatedTreeRepresentation(postLGG,endpoint.getBaseURI(),endpoint.getPrefixes()));
  logger.info("String_Node_Str" + postLGG.toSPARQLQueryString());
  logger.info("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=getAllowedGeneralisationsSorted(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=getAllowedGeneralisationsSorted(tmp);
      }
      if (gens.isEmpty()) {
        if (logger.isDebugEnabled()) {
          logger.debug("String_Node_Str");
        }
        break;
      }
      tmp=getGeneralisedQueryTreeNotContainingNoSequence(gens);
      neededGeneralisations.add(tmp);
      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) {
      if (index == -1) {
        tree2=tmp;
      }
      tree2=neededGeneralisations.get(index--);
    }
 else {
      tree2=tmp;
    }
    String newResource=getNewResource2(fSparql(lgg,tree2.getChanges()),knownResources);
    if (isTerminationCriteriaReached()) {
      throw new TimeOutException(maxExecutionTimeInSeconds);
    }
    fSparql(postLGG,tmp.getChanges());
    logger.debug("String_Node_Str" + newResource);
    if (!(newResource == null)) {
      logger.debug("String_Node_Str");
      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;
}