Program: 189279
Project: 189279
Buggy source:
/** 
 * This method produces the common part of the query handle the filter search clauses. 
 * @param andQuery The existing and-based query
 * @param filter The filter search paramaters.
 * @param submissions Whether this is for submissions or action logs
 */
public void buildQuery(BooleanQuery andQuery,SearchFilter filter,boolean submissions){
  QueryParser parser=new QueryParser(indexer.version,"String_Node_Str",indexer.standardAnalyzer);
  if (filter.getIncludedSubmissions().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    Submission sub : filter.getIncludedSubmissions()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",NumericUtils.longToPrefixCoded(sub.getId()))),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getIncludedActionLogs().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    ActionLog log : filter.getIncludedActionLogs()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",NumericUtils.longToPrefixCoded(log.getId()))),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  for (  Submission sub : filter.getExcludedSubmissions()) {
    andQuery.add(new TermQuery(new Term("String_Node_Str",NumericUtils.longToPrefixCoded(sub.getId()))),Occur.MUST_NOT);
  }
  for (  ActionLog log : filter.getExcludedActionLogs()) {
    andQuery.add(new TermQuery(new Term("String_Node_Str",NumericUtils.longToPrefixCoded(log.getId()))),Occur.MUST_NOT);
  }
  if (filter.getSearchText().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String searchText : filter.getSearchText()) {
      try {
        orQuery.add(parser.parse(searchText),Occur.SHOULD);
      }
 catch (      ParseException e) {
        orQuery.add(new TermQuery(new Term("String_Node_Str",searchText)),Occur.SHOULD);
      }
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getStates().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String stateName : filter.getStates()) {
      State state=stateManager.getState(stateName);
      orQuery.add(new TermQuery(new Term("String_Node_Str",state.getDisplayName())),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getAssignees().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    Person assignee : filter.getAssignees()) {
      long assigneeId=0;
      if (assignee != null)       assigneeId=assignee.getId();
      orQuery.add(new TermQuery(new Term("String_Node_Str",NumericUtils.longToPrefixCoded(assigneeId))),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getEmbargoTypes().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    EmbargoType embargo : filter.getEmbargoTypes()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",embargo.getName())),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getGraduationSemesters().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    Semester semester : filter.getGraduationSemesters()) {
      if (semester.year == null)       continue;
      Calendar cal=Calendar.getInstance();
      cal.clear();
      cal.set(Calendar.YEAR,semester.year);
      if (semester.month != null) {
        cal.set(Calendar.MONTH,semester.month);
      }
      orQuery.add(new TermQuery(new Term("String_Node_Str",NumericUtils.longToPrefixCoded(cal.getTimeInMillis()))),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getDegrees().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String degree : filter.getDegrees()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",degree)),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getDepartments().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String dept : filter.getDepartments()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",dept)),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getPrograms().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String program : filter.getPrograms()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",program)),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getColleges().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String college : filter.getColleges()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",college)),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getMajors().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String major : filter.getMajors()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",major)),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getDocumentTypes().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String docType : filter.getDocumentTypes()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",docType)),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getUMIRelease() != null) {
    if (filter.getUMIRelease()) {
      andQuery.add(new TermQuery(new Term("String_Node_Str","String_Node_Str")),Occur.MUST);
    }
 else {
      andQuery.add(new TermQuery(new Term("String_Node_Str","String_Node_Str")),Occur.MUST);
    }
  }
  if (filter.getDateRangeStart() != null || filter.getDateRangeEnd() != null) {
    long startTime=0;
    if (filter.getDateRangeStart() != null)     startTime=filter.getDateRangeStart().getTime();
    long endTime=Long.MAX_VALUE;
    if (filter.getDateRangeEnd() != null)     endTime=filter.getDateRangeEnd().getTime();
    if (submissions)     andQuery.add(NumericRangeQuery.newLongRange("String_Node_Str",startTime,endTime,true,true),Occur.MUST);
 else     andQuery.add(NumericRangeQuery.newLongRange("String_Node_Str",startTime,endTime,true,true),Occur.MUST);
  }
  if (filter.getCustomActions().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    CustomActionDefinition customAction : filter.getCustomActions()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",customAction.getLabel())),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
}

Fixed version (ground truth):
/** 
 * This method produces the common part of the query handle the filter search clauses. 
 * @param andQuery The existing and-based query
 * @param filter The filter search paramaters.
 * @param submissions Whether this is for submissions or action logs
 */
public void buildQuery(BooleanQuery andQuery,SearchFilter filter,boolean submissions){
  QueryParser parser=new QueryParser(indexer.version,"String_Node_Str",indexer.standardAnalyzer);
  if (filter.getIncludedSubmissions().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    Submission sub : filter.getIncludedSubmissions()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",NumericUtils.longToPrefixCoded(sub.getId()))),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getIncludedActionLogs().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    ActionLog log : filter.getIncludedActionLogs()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",NumericUtils.longToPrefixCoded(log.getId()))),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  for (  Submission sub : filter.getExcludedSubmissions()) {
    andQuery.add(new TermQuery(new Term("String_Node_Str",NumericUtils.longToPrefixCoded(sub.getId()))),Occur.MUST_NOT);
  }
  for (  ActionLog log : filter.getExcludedActionLogs()) {
    andQuery.add(new TermQuery(new Term("String_Node_Str",NumericUtils.longToPrefixCoded(log.getId()))),Occur.MUST_NOT);
  }
  if (filter.getSearchText().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String searchText : filter.getSearchText()) {
      try {
        orQuery.add(parser.parse(searchText),Occur.SHOULD);
      }
 catch (      ParseException e) {
        orQuery.add(new TermQuery(new Term("String_Node_Str",searchText)),Occur.SHOULD);
      }
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getStates().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String stateName : filter.getStates()) {
      State state=stateManager.getState(stateName);
      orQuery.add(new TermQuery(new Term("String_Node_Str",state.getDisplayName())),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getAssignees().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    Person assignee : filter.getAssignees()) {
      long assigneeId=0;
      if (assignee != null)       assigneeId=assignee.getId();
      orQuery.add(new TermQuery(new Term("String_Node_Str",NumericUtils.longToPrefixCoded(assigneeId))),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getEmbargoTypes().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    EmbargoType embargo : filter.getEmbargoTypes()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",embargo.getName() + "String_Node_Str" + embargo.getGuarantor().name())),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getGraduationSemesters().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    Semester semester : filter.getGraduationSemesters()) {
      if (semester.year == null)       continue;
      Calendar cal=Calendar.getInstance();
      cal.clear();
      cal.set(Calendar.YEAR,semester.year);
      if (semester.month != null) {
        cal.set(Calendar.MONTH,semester.month);
      }
      orQuery.add(new TermQuery(new Term("String_Node_Str",NumericUtils.longToPrefixCoded(cal.getTimeInMillis()))),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getDegrees().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String degree : filter.getDegrees()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",degree)),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getDepartments().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String dept : filter.getDepartments()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",dept)),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getPrograms().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String program : filter.getPrograms()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",program)),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getColleges().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String college : filter.getColleges()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",college)),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getMajors().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String major : filter.getMajors()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",major)),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getDocumentTypes().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    String docType : filter.getDocumentTypes()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",docType)),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
  if (filter.getUMIRelease() != null) {
    if (filter.getUMIRelease()) {
      andQuery.add(new TermQuery(new Term("String_Node_Str","String_Node_Str")),Occur.MUST);
    }
 else {
      andQuery.add(new TermQuery(new Term("String_Node_Str","String_Node_Str")),Occur.MUST);
    }
  }
  if (filter.getDateRangeStart() != null || filter.getDateRangeEnd() != null) {
    long startTime=0;
    if (filter.getDateRangeStart() != null)     startTime=filter.getDateRangeStart().getTime();
    long endTime=Long.MAX_VALUE;
    if (filter.getDateRangeEnd() != null)     endTime=filter.getDateRangeEnd().getTime();
    if (submissions)     andQuery.add(NumericRangeQuery.newLongRange("String_Node_Str",startTime,endTime,true,true),Occur.MUST);
 else     andQuery.add(NumericRangeQuery.newLongRange("String_Node_Str",startTime,endTime,true,true),Occur.MUST);
  }
  if (filter.getCustomActions().size() > 0) {
    BooleanQuery orQuery=new BooleanQuery();
    for (    CustomActionDefinition customAction : filter.getCustomActions()) {
      orQuery.add(new TermQuery(new Term("String_Node_Str",customAction.getLabel())),Occur.SHOULD);
    }
    andQuery.add(orQuery,Occur.MUST);
  }
}