Program: 24782
Project: 24782
Buggy source:
/** 
 * Main work of recursively parsing a query. 
 */
private Query parseQuery2(EasyNode parent,String name,String field,int maxSnippets) throws QueryGenException {
  if (name.equals("String_Node_Str")) {
    Term term=parseTerm(parent,field,"String_Node_Str");
    SpanQuery q=isWildcardTerm(term) ? new BigramSpanWildcardQuery(term,req.termLimit) : new SpanTermQuery(term);
    q.setSpanRecording(maxSnippets);
    return q;
  }
  field=parseField(parent,field);
  if (name.equals("String_Node_Str"))   return parseRange(parent,field,maxSnippets);
  if (name.equals("String_Node_Str"))   return parseMoreLike(parent,field,maxSnippets);
  if (name.matches("String_Node_Str")) {
    int slop=name.equals("String_Node_Str") ? 999999999 : name.equals("String_Node_Str") ? 0 : name.equals("String_Node_Str") ? -1 : parseIntAttrib(parent,"String_Node_Str");
    return makeProxQuery(parent,slop,field,maxSnippets);
  }
  HashMap subMap=new HashMap();
  Vector fields=new Vector();
  BooleanQuery bq=new BooleanQuery();
  boolean require=!name.equals("String_Node_Str");
  for (int i=0; i < parent.nChildren(); i++) {
    EasyNode el=parent.child(i);
    if (!el.isElement())     continue;
    if (el.name().equals("String_Node_Str"))     continue;
 else     if (el.name().equalsIgnoreCase("String_Node_Str"))     continue;
    Query q;
    boolean isNot=false;
    if (el.name().equals("String_Node_Str")) {
      q=parseQuery2(el,name,field,0);
      isNot=true;
    }
 else     q=parseQuery(el,field,maxSnippets);
    if (q == null)     continue;
    if (q instanceof SpanQuery) {
      String queryField=((SpanQuery)q).getField();
      QueryEntry ent=(QueryEntry)subMap.get(queryField);
      if (ent == null) {
        fields.add(queryField);
        ent=new QueryEntry(queryField);
        subMap.put(queryField,ent);
      }
      if (isNot)       ent.nots.add(q);
 else       ent.queries.add(q);
    }
 else {
      bq.add(q,isNot ? false : require,isNot);
    }
  }
  BooleanClause[] genericClauses=bq.getClauses();
  if (genericClauses.length == 0) {
    if (subMap.isEmpty())     return null;
    if (fields.size() == 1) {
      QueryEntry ent=(QueryEntry)subMap.get(fields.get(0));
      if (ent.nots.isEmpty()) {
        return processSpanJoin(name,ent.queries,ent.nots,maxSnippets);
      }
    }
  }
  for (int i=0; i < fields.size(); i++) {
    QueryEntry ent=(QueryEntry)subMap.get(fields.get(i));
    int nQueries=ent.queries.size();
    int nNots=ent.nots.size();
    if (nQueries > 1 || (nQueries == 1 && nNots > 0)) {
      SpanQuery sq=processSpanJoin(name,ent.queries,ent.nots,maxSnippets);
      bq.add(deChunk(sq),require,false);
      continue;
    }
    for (int j=0; j < ent.queries.size(); j++)     bq.add(deChunk((Query)ent.queries.get(j)),require,false);
    for (int j=0; j < ent.nots.size(); j++)     bq.add(deChunk((Query)ent.nots.get(j)),false,true);
  }
  BooleanClause[] clauses=bq.getClauses();
  if (clauses.length == 1) {
    if (clauses[0].required)     return clauses[0].query;
 else     if (clauses[0].prohibited) {
      Query allDocsQuery=new TermQuery(new Term("String_Node_Str","String_Node_Str"));
      bq.add(allDocsQuery,true,false);
    }
  }
  return simplifyBooleanQuery(bq);
}

Fixed version (ground truth):
/** 
 * Main work of recursively parsing a query. 
 */
private Query parseQuery2(EasyNode parent,String name,String field,int maxSnippets) throws QueryGenException {
  if (name.equals("String_Node_Str")) {
    Term term=parseTerm(parent,field,"String_Node_Str");
    SpanQuery q=isWildcardTerm(term) ? new XtfSpanWildcardQuery(term,req.termLimit) : new SpanTermQuery(term);
    q.setSpanRecording(maxSnippets);
    return q;
  }
  field=parseField(parent,field);
  if (name.equals("String_Node_Str"))   return parseRange(parent,field,maxSnippets);
  if (name.equals("String_Node_Str"))   return parseMoreLike(parent,field,maxSnippets);
  if (name.matches("String_Node_Str")) {
    int slop=name.equals("String_Node_Str") ? 999999999 : name.equals("String_Node_Str") ? 0 : name.equals("String_Node_Str") ? -1 : parseIntAttrib(parent,"String_Node_Str");
    return makeProxQuery(parent,slop,field,maxSnippets);
  }
  HashMap subMap=new HashMap();
  Vector fields=new Vector();
  BooleanQuery bq=new BooleanQuery();
  boolean require=!name.equals("String_Node_Str");
  for (int i=0; i < parent.nChildren(); i++) {
    EasyNode el=parent.child(i);
    if (!el.isElement())     continue;
    if (el.name().equals("String_Node_Str"))     continue;
 else     if (el.name().equalsIgnoreCase("String_Node_Str"))     continue;
    Query q;
    boolean isNot=false;
    if (el.name().equals("String_Node_Str")) {
      q=parseQuery2(el,name,field,0);
      isNot=true;
    }
 else     q=parseQuery(el,field,maxSnippets);
    if (q == null)     continue;
    if (q instanceof SpanQuery) {
      String queryField=((SpanQuery)q).getField();
      QueryEntry ent=(QueryEntry)subMap.get(queryField);
      if (ent == null) {
        fields.add(queryField);
        ent=new QueryEntry(queryField);
        subMap.put(queryField,ent);
      }
      if (isNot)       ent.nots.add(q);
 else       ent.queries.add(q);
    }
 else {
      bq.add(q,isNot ? false : require,isNot);
    }
  }
  BooleanClause[] genericClauses=bq.getClauses();
  if (genericClauses.length == 0) {
    if (subMap.isEmpty())     return null;
    if (fields.size() == 1) {
      QueryEntry ent=(QueryEntry)subMap.get(fields.get(0));
      if (ent.nots.isEmpty()) {
        return processSpanJoin(name,ent.queries,ent.nots,maxSnippets);
      }
    }
  }
  for (int i=0; i < fields.size(); i++) {
    QueryEntry ent=(QueryEntry)subMap.get(fields.get(i));
    int nQueries=ent.queries.size();
    int nNots=ent.nots.size();
    if (nQueries > 1 || (nQueries == 1 && nNots > 0)) {
      SpanQuery sq=processSpanJoin(name,ent.queries,ent.nots,maxSnippets);
      bq.add(deChunk(sq),require,false);
      continue;
    }
    for (int j=0; j < ent.queries.size(); j++)     bq.add(deChunk((Query)ent.queries.get(j)),require,false);
    for (int j=0; j < ent.nots.size(); j++)     bq.add(deChunk((Query)ent.nots.get(j)),false,true);
  }
  BooleanClause[] clauses=bq.getClauses();
  if (clauses.length == 1) {
    if (clauses[0].required)     return clauses[0].query;
 else     if (clauses[0].prohibited) {
      Query allDocsQuery=new TermQuery(new Term("String_Node_Str","String_Node_Str"));
      bq.add(allDocsQuery,true,false);
    }
  }
  return simplifyBooleanQuery(bq);
}