Program: 12365
Project: 12365
Buggy source:
private int generateNewContexts(List<Integer> docIds){
  int count=0;
  Set<Integer> firstTokenIndexes=new HashSet<>();
  for (  int docId : docIds) {
    count++;
    try {
      Terms lookupVector=SolrUtil.getTermVector(docId,properties.getSolrFieldnameJATENGramInfo(),solrIndexSearcher);
      Map<Integer,Integer> sentenceBoundaries=new HashMap<>();
      List<MWEInSentence> terms=collectTermSentenceContext(lookupVector,sentenceBoundaries);
      int lastToken=-1;
      int currSentenceId=-1, currWindowStart=-1, currWindowEnd=-1;
      ContextWindow prevCtx=null;
      List<Integer> prevWindowRight=new ArrayList<>();
      for (int i=0; i < terms.size(); i++) {
        MWEInSentence term=terms.get(i);
        firstTokenIndexes.add(term.firstTokenIndex);
        if (currSentenceId == -1 || (currSentenceId != -1 && term.sentenceId != currSentenceId)) {
          currSentenceId=term.sentenceId;
          currWindowStart=-1;
          currWindowEnd=-1;
          lastToken=sentenceBoundaries.get(currSentenceId);
        }
        if (term.firstTokenIndex >= currWindowStart && term.firstTokenIndex <= currWindowEnd)         continue;
        currWindowStart=term.firstTokenIndex - window;
        if (currWindowStart < 0)         currWindowStart=0;
        currWindowEnd=term.lastTokenIndex + window;
        if (currWindowEnd >= lastToken)         currWindowEnd=lastToken;
        ContextWindow ctx=new ContextWindow();
        ctx.setDocId(docId);
        ctx.setSentenceId(currSentenceId);
        ctx.setFirstTok(currWindowStart);
        ctx.setLastTok(currWindowEnd);
        if (docId == 399 && currSentenceId == 1 && currWindowStart == 5 && currWindowEnd == 17)         System.out.println("String_Node_Str");
        if (docId == 399 && currSentenceId == 1 && currWindowStart == 13 && currWindowEnd == 23)         System.out.println("String_Node_Str");
        feature.increment(ctx,1);
        feature.increment(ctx,term.string,1);
        List<String> termsInOverlap=new ArrayList<>();
        List<Integer> currentWindowRight=new ArrayList<>();
        for (int j=i - 1; j > -1; j--) {
          MWEInSentence prevTerm=terms.get(j);
          if (prevWindowRight.size() > 0) {
            if (j < prevWindowRight.get(0))             break;
          }
 else           if (prevTerm.lastTokenIndex < currWindowStart || prevTerm.sentenceId != ctx.getSentenceId())           break;
          if ((prevTerm.firstTokenIndex >= ctx.getFirstTok() && prevTerm.firstTokenIndex <= ctx.getLastTok()) || (prevTerm.lastTokenIndex >= ctx.getFirstTok() && prevTerm.lastTokenIndex <= ctx.getLastTok())) {
            feature.increment(ctx,1);
            feature.increment(ctx,prevTerm.string,1);
            if (prevWindowRight.contains(j)) {
              termsInOverlap.add(prevTerm.string);
            }
          }
          if (prevTerm.sentenceId == term.sentenceId && prevTerm.lastTokenIndex > term.lastTokenIndex)           currentWindowRight.add(j);
        }
        if (prevCtx != null && prevCtx.getSentenceId() == ctx.getSentenceId() && termsInOverlap.size() > 0 && prevCtx.getLastTok() >= ctx.getFirstTok()) {
          ContextOverlap co=new ContextOverlap(prevCtx,ctx,termsInOverlap);
          feature.addCtxOverlapZone(co);
        }
        for (int j=i + 1; j < terms.size(); j++) {
          i=j - 1;
          MWEInSentence nextTerm=terms.get(j);
          if (nextTerm.firstTokenIndex > currWindowEnd || nextTerm.sentenceId != ctx.getSentenceId())           break;
          feature.increment(ctx,1);
          feature.increment(ctx,nextTerm.string,1);
          currentWindowRight.add(j);
        }
        prevWindowRight=currentWindowRight;
        prevCtx=ctx;
      }
    }
 catch (    IOException ioe) {
      StringBuilder sb=new StringBuilder("String_Node_Str");
      sb.append(docId).append("String_Node_Str");
      sb.append(ExceptionUtils.getFullStackTrace(ioe));
      LOG.severe(sb.toString());
    }
catch (    JATEException je) {
      StringBuilder sb=new StringBuilder("String_Node_Str");
      sb.append(docId).append("String_Node_Str");
      sb.append(ExceptionUtils.getFullStackTrace(je));
      LOG.severe(sb.toString());
    }
  }
  if (firstTokenIndexes.size() / docIds.size() <= 1)   try {
    LOG.warning("String_Node_Str" + properties.getSolrFieldnameJATENGramInfo() + "String_Node_Str");
  }
 catch (  JATEException e) {
  }
  return count;
}

Fixed version (ground truth):
private int generateNewContexts(List<Integer> docIds){
  int count=0;
  Set<Integer> firstTokenIndexes=new HashSet<>();
  for (  int docId : docIds) {
    count++;
    try {
      Terms lookupVector=SolrUtil.getTermVector(docId,properties.getSolrFieldnameJATENGramInfo(),solrIndexSearcher);
      Map<Integer,Integer> sentenceBoundaries=new HashMap<>();
      List<MWEInSentence> terms=collectTermSentenceContext(lookupVector,sentenceBoundaries);
      int lastToken=-1;
      int currSentenceId=-1, currWindowStart=-1, currWindowEnd=-1;
      ContextWindow prevCtx=null;
      List<Integer> prevWindowRight=new ArrayList<>();
      for (int i=0; i < terms.size(); i++) {
        MWEInSentence term=terms.get(i);
        firstTokenIndexes.add(term.firstTokenIndex);
        if (currSentenceId == -1 || (currSentenceId != -1 && term.sentenceId != currSentenceId)) {
          currSentenceId=term.sentenceId;
          currWindowStart=-1;
          currWindowEnd=-1;
          lastToken=sentenceBoundaries.get(currSentenceId);
        }
        if (term.firstTokenIndex >= currWindowStart && term.firstTokenIndex <= currWindowEnd)         continue;
        currWindowStart=term.firstTokenIndex - window;
        if (currWindowStart < 0)         currWindowStart=0;
        currWindowEnd=term.lastTokenIndex + window;
        if (currWindowEnd >= lastToken)         currWindowEnd=lastToken;
        ContextWindow ctx=new ContextWindow();
        ctx.setDocId(docId);
        ctx.setSentenceId(currSentenceId);
        ctx.setFirstTok(currWindowStart);
        ctx.setLastTok(currWindowEnd);
        feature.increment(ctx,1);
        feature.increment(ctx,term.string,1);
        List<String> termsInOverlap=new ArrayList<>();
        List<Integer> currentWindowRight=new ArrayList<>();
        for (int j=i - 1; j > -1; j--) {
          MWEInSentence prevTerm=terms.get(j);
          if (prevWindowRight.size() > 0) {
            if (j < prevWindowRight.get(0))             break;
          }
 else           if (prevTerm.lastTokenIndex < currWindowStart || prevTerm.sentenceId != ctx.getSentenceId())           break;
          if ((prevTerm.firstTokenIndex >= ctx.getFirstTok() && prevTerm.firstTokenIndex <= ctx.getLastTok()) || (prevTerm.lastTokenIndex >= ctx.getFirstTok() && prevTerm.lastTokenIndex <= ctx.getLastTok())) {
            feature.increment(ctx,1);
            feature.increment(ctx,prevTerm.string,1);
            if (prevWindowRight.contains(j)) {
              termsInOverlap.add(prevTerm.string);
            }
          }
          if (prevTerm.sentenceId == term.sentenceId && prevTerm.lastTokenIndex > term.lastTokenIndex)           currentWindowRight.add(j);
        }
        if (prevCtx != null && prevCtx.getSentenceId() == ctx.getSentenceId() && termsInOverlap.size() > 0 && prevCtx.getLastTok() >= ctx.getFirstTok()) {
          ContextOverlap co=new ContextOverlap(prevCtx,ctx,termsInOverlap);
          feature.addCtxOverlapZone(co);
        }
        for (int j=i + 1; j < terms.size(); j++) {
          i=j - 1;
          MWEInSentence nextTerm=terms.get(j);
          if (nextTerm.firstTokenIndex > currWindowEnd || nextTerm.sentenceId != ctx.getSentenceId())           break;
          feature.increment(ctx,1);
          feature.increment(ctx,nextTerm.string,1);
          currentWindowRight.add(j);
        }
        prevWindowRight=currentWindowRight;
        prevCtx=ctx;
      }
    }
 catch (    IOException ioe) {
      StringBuilder sb=new StringBuilder("String_Node_Str");
      sb.append(docId).append("String_Node_Str");
      sb.append(ExceptionUtils.getFullStackTrace(ioe));
      LOG.severe(sb.toString());
    }
catch (    JATEException je) {
      StringBuilder sb=new StringBuilder("String_Node_Str");
      sb.append(docId).append("String_Node_Str");
      sb.append(ExceptionUtils.getFullStackTrace(je));
      LOG.severe(sb.toString());
    }
  }
  if (firstTokenIndexes.size() / docIds.size() <= 1)   try {
    LOG.warning("String_Node_Str" + properties.getSolrFieldnameJATENGramInfo() + "String_Node_Str");
  }
 catch (  JATEException e) {
  }
  return count;
}