Program: 30741
Project: 30741
Buggy source:
private QueryModel parseJoin(CharSequence tok,int joinType,QueryModel parent) throws ParserException {
  QueryModel joinModel=queryModelPool.next();
  joinModel.setJoinType(joinType);
  if (!Chars.equals(tok,"String_Node_Str")) {
    expectTok(tok(),"String_Node_Str");
  }
  tok=tok();
  if (Chars.equals(tok,'(')) {
    joinModel.setNestedModel(parseQuery(true));
    expectTok(')');
  }
 else {
    lexer.unparse();
    parseWithClauseOrJournalName(joinModel,parent);
  }
  tok=lexer.optionTok();
  if (tok != null && !journalAliasStop.contains(tok)) {
    lexer.unparse();
    joinModel.setAlias(expr());
  }
 else {
    lexer.unparse();
  }
  tok=lexer.optionTok();
  if (joinType == QueryModel.JOIN_CROSS && tok != null && Chars.equals(tok,"String_Node_Str")) {
    throw ParserException.$(lexer.position(),"String_Node_Str");
  }
switch (joinType) {
case QueryModel.JOIN_ASOF:
    if (tok == null || !Chars.equals("String_Node_Str",tok)) {
      lexer.unparse();
      break;
    }
case QueryModel.JOIN_INNER:
case QueryModel.JOIN_OUTER:
  expectTok(tok,"String_Node_Str");
astBuilder.reset();
exprParser.parseExpr(lexer,astBuilder);
ExprNode expr;
switch (astBuilder.size()) {
case 0:
throw ParserException.$(lexer.position(),"String_Node_Str");
case 1:
expr=astBuilder.poll();
if (expr.type == ExprNode.LITERAL) {
do {
joinModel.addJoinColumn(expr);
}
 while ((expr=astBuilder.poll()) != null);
}
 else {
joinModel.setJoinCriteria(expr);
}
break;
default :
while ((expr=astBuilder.poll()) != null) {
if (expr.type != ExprNode.LITERAL) {
throw ParserException.$(lexer.position(),"String_Node_Str");
}
joinModel.addJoinColumn(expr);
}
break;
}
break;
default :
lexer.unparse();
}
return joinModel;
}

Fixed version (ground truth):
private QueryModel parseJoin(CharSequence tok,int joinType,QueryModel parent) throws ParserException {
  QueryModel joinModel=queryModelPool.next();
  joinModel.setJoinType(joinType);
  if (!Chars.equals(tok,"String_Node_Str")) {
    expectTok("String_Node_Str");
  }
  tok=tok();
  if (Chars.equals(tok,'(')) {
    joinModel.setNestedModel(parseQuery(true));
    expectTok(')');
  }
 else {
    lexer.unparse();
    parseWithClauseOrJournalName(joinModel,parent);
  }
  tok=lexer.optionTok();
  if (tok != null && !journalAliasStop.contains(tok)) {
    lexer.unparse();
    joinModel.setAlias(expr());
  }
 else {
    lexer.unparse();
  }
  tok=lexer.optionTok();
  if (joinType == QueryModel.JOIN_CROSS && tok != null && Chars.equals(tok,"String_Node_Str")) {
    throw ParserException.$(lexer.position(),"String_Node_Str");
  }
switch (joinType) {
case QueryModel.JOIN_ASOF:
    if (tok == null || !Chars.equals("String_Node_Str",tok)) {
      lexer.unparse();
      break;
    }
case QueryModel.JOIN_INNER:
case QueryModel.JOIN_OUTER:
  expectTok(tok,lexer.position(),"String_Node_Str");
astBuilder.reset();
exprParser.parseExpr(lexer,astBuilder);
ExprNode expr;
switch (astBuilder.size()) {
case 0:
throw ParserException.$(lexer.position(),"String_Node_Str");
case 1:
expr=astBuilder.poll();
if (expr.type == ExprNode.LITERAL) {
do {
joinModel.addJoinColumn(expr);
}
 while ((expr=astBuilder.poll()) != null);
}
 else {
joinModel.setJoinCriteria(expr);
}
break;
default :
while ((expr=astBuilder.poll()) != null) {
if (expr.type != ExprNode.LITERAL) {
throw ParserException.$(lexer.position(),"String_Node_Str");
}
joinModel.addJoinColumn(expr);
}
break;
}
break;
default :
lexer.unparse();
}
return joinModel;
}