Program: 146577
Project: 146577
Buggy source:
private boolean answerQuestion(String input) throws BadPlaybackException, InvalidInputException {
switch (fec.getModel().getEvent()) {
case FormEntryController.EVENT_BEGINNING_OF_FORM:
    environment.recordAction(new Action(new Command("String_Node_Str")));
  fec.stepToNextEvent();
return false;
case FormEntryController.EVENT_END_OF_FORM:
environment.recordAction(new Action(new Command("String_Node_Str")));
mProcessOnExit=true;
return true;
case FormEntryController.EVENT_QUESTION:
FormEntryPrompt fep=fec.getModel().getQuestionPrompt();
String actualInput=input;
if (environment.isModePlayback()) {
actualInput=this.current.getAction().getRawAnswer();
}
 else {
Vector<SelectChoice> choices=fep.getSelectChoices();
if (choices != null) {
if (input.equals("String_Node_Str") && fep.getQuestion().getControlType() == Constants.CONTROL_SELECT_MULTI) {
Vector<Selection> answers=new Vector<>();
for (int i=0; i < mCurrentSelectList.length; ++i) {
if (mCurrentSelectList[i]) {
answers.addElement(choices.elementAt(i).selection());
}
}
actualInput=new SelectMultiData(answers).uncast().getString();
}
 else {
int index=parseAndValidate(input,choices.size()) - 1;
if (fep.getQuestion().getControlType() == Constants.CONTROL_SELECT_ONE) {
actualInput=choices.elementAt(index).getValue();
}
if (fep.getQuestion().getControlType() == Constants.CONTROL_SELECT_MULTI) {
this.mCurrentSelectList[index]=!this.mCurrentSelectList[index];
return false;
}
}
}
}
try {
IAnswerData value=actualInput.equals("String_Node_Str") ? null : AnswerDataFactory.template(fep.getControlType(),fep.getDataType()).cast(new UncastData(actualInput));
int response=fec.answerQuestion(value);
if (environment.isModePlayback()) {
ActionResponse actionResponse=current.getAction().getActionResponse();
actionResponse.validate(response,actualInput,fep);
}
if (response == FormEntryController.ANSWER_OK) {
environment.recordAction(new Action(actualInput));
fec.stepToNextEvent();
return false;
}
 else if (response == FormEntryController.ANSWER_REQUIRED_BUT_EMPTY) {
environment.recordAction(new Action(actualInput,ActionResponse.QuestionRequired()));
badInput(input,"String_Node_Str");
return false;
}
 else if (response == FormEntryController.ANSWER_CONSTRAINT_VIOLATED) {
environment.recordAction(new Action(actualInput,ActionResponse.ConstraintViolated()));
badInput(input,fep.getConstraintText());
return false;
}
}
 catch (Exception e) {
e.printStackTrace();
badInput(input,e.getMessage());
return false;
}
return false;
case FormEntryController.EVENT_REPEAT:
return true;
case FormEntryController.EVENT_REPEAT_JUNCTURE:
return true;
case FormEntryController.EVENT_PROMPT_NEW_REPEAT:
int index=parseAndValidate(input,2);
if (index == 1) {
fec.newRepeat();
fec.stepToNextEvent();
return false;
}
 else if (index == 2) {
fec.stepToNextEvent();
return false;
}
}
out.println("String_Node_Str");
return true;
}

Fixed version (ground truth):
private boolean answerQuestion(String input) throws BadPlaybackException, InvalidInputException {
switch (fec.getModel().getEvent()) {
case FormEntryController.EVENT_BEGINNING_OF_FORM:
    environment.recordAction(new Action(new Command("String_Node_Str")));
  fec.stepToNextEvent();
return false;
case FormEntryController.EVENT_END_OF_FORM:
environment.recordAction(new Action(new Command("String_Node_Str")));
mProcessOnExit=true;
return true;
case FormEntryController.EVENT_QUESTION:
FormEntryPrompt fep=fec.getModel().getQuestionPrompt();
String actualInput=input;
if (environment.isModePlayback()) {
actualInput=this.current.getAction().getRawAnswer();
}
 else {
Vector<SelectChoice> choices=fep.getSelectChoices();
if (choices != null) {
if (input.equals("String_Node_Str") && fep.getQuestion().getControlType() == Constants.CONTROL_SELECT_MULTI) {
Vector<Selection> answers=new Vector<>();
for (int i=0; i < mCurrentSelectList.length; ++i) {
if (mCurrentSelectList[i]) {
answers.addElement(choices.elementAt(i).selection());
}
}
actualInput=new SelectMultiData(answers).uncast().getString();
}
 else {
int index=parseAndValidate(input,choices.size()) - 1;
if (fep.getQuestion().getControlType() == Constants.CONTROL_SELECT_ONE) {
actualInput=choices.elementAt(index).getValue();
}
if (fep.getQuestion().getControlType() == Constants.CONTROL_SELECT_MULTI) {
this.mCurrentSelectList[index]=!this.mCurrentSelectList[index];
return false;
}
}
}
}
try {
IAnswerData value=actualInput.equals("String_Node_Str") ? null : AnswerDataFactory.template(fep.getControlType(),fep.getDataType()).cast(new UncastData(actualInput));
int response=fec.answerQuestion(value);
if (environment.isModePlayback()) {
ActionResponse actionResponse=current.getAction().getActionResponse();
actionResponse.validate(response,actualInput,fep);
}
if (response == FormEntryController.ANSWER_OK) {
environment.recordAction(new Action(actualInput));
fec.stepToNextEvent();
return false;
}
 else if (response == FormEntryController.ANSWER_REQUIRED_BUT_EMPTY) {
environment.recordAction(new Action(actualInput,ActionResponse.QuestionRequired()));
badInput(input,"String_Node_Str");
return false;
}
 else if (response == FormEntryController.ANSWER_CONSTRAINT_VIOLATED) {
environment.recordAction(new Action(actualInput,ActionResponse.ConstraintViolated()));
badInput(input,fep.getConstraintText());
return false;
}
}
 catch (InvalidInputException e) {
throw e;
}
catch (Exception e) {
e.printStackTrace();
badInput(input,e.getMessage());
return false;
}
return false;
case FormEntryController.EVENT_REPEAT:
return true;
case FormEntryController.EVENT_REPEAT_JUNCTURE:
return true;
case FormEntryController.EVENT_PROMPT_NEW_REPEAT:
int index=parseAndValidate(input,2);
if (index == 1) {
fec.newRepeat();
fec.stepToNextEvent();
return false;
}
 else if (index == 2) {
fec.stepToNextEvent();
return false;
}
}
out.println("String_Node_Str");
return true;
}