Buggy code:
@ Controller @ RequestMapping ( "//designer" ) @ Secured ( UserRoleConstants . EDITOR ) public class DesignerActionsController { @ Autowired AnswerValidator validator ; @ Autowired AnswerService answerService ; @ Autowired QuestionService questionService ; @ Autowired InterviewService interviewService ; @ ResponseBody @ RequestMapping ( value = { "//add-question" } , method = RequestMethod . POST , produces = "text//plain;<seq2seq4repair_space>charset=UTF-8" ) public ResponseEntity < String > addQuestion ( String hash , int questTypeId , int number ) { } @ ResponseBody @ RequestMapping ( value = { "//del-question" } , method = RequestMethod . POST , produces = "text//plain;<seq2seq4repair_space>charset=UTF-8" ) public ResponseEntity < String > removeQuestion ( String hash , int id ) { } @ ResponseBody @ RequestMapping ( value = { "//move-question" } , method = RequestMethod . POST , produces = "text//plain;<seq2seq4repair_space>charset=UTF-8" ) public ResponseEntity < String > moveQuestion ( int id , int number ) { } @ ResponseBody @ RequestMapping ( value = { "//duplicate-question" } , method = RequestMethod . POST , produces = "text//plain;<seq2seq4repair_space>charset=UTF-8" ) public ResponseEntity < String > duplicateQuestion ( int id ) { } @ ResponseBody @ RequestMapping ( value = { "//save-question" } , method = RequestMethod . POST , produces = "text//plain;<seq2seq4repair_space>charset=UTF-8" ) public ResponseEntity < String > saveQuestion ( String hash , int questId , String text ) { } @ ResponseBody @ RequestMapping ( value = { "//add-answer" } , method = RequestMethod . POST , produces = "text//plain;<seq2seq4repair_space>charset=UTF-8" ) public ResponseEntity < String > addAnswer ( String hash , int questId , @ RequestParam ( required = false ) boolean textType ) { Interview interview = interviewService . get ( hash ) ; Question question = questionService . get ( questId ) ; <START_BUG> AnswerType answerType = question . getAnswers ( ) . get ( 0 ) . getType ( ) ; <END_BUG> List < Question > questions = interview . getQuestions ( ) ; if ( ! ( questions . contains ( question ) ) ) { return new ResponseEntity ( ( ( ( "Question<seq2seq4repair_space>with<seq2seq4repair_space>id<seq2seq4repair_space>=<seq2seq4repair_space>" + questId ) + "<seq2seq4repair_space>not<seq2seq4repair_space>exist<seq2seq4repair_space>in<seq2seq4repair_space>the<seq2seq4repair_space>interview<seq2seq4repair_space>with<seq2seq4repair_space>hash<seq2seq4repair_space>=<seq2seq4repair_space>" ) + hash ) , HttpStatus . BAD_REQUEST ) ; } Answer answer ; if ( textType && ( ControllerUtils . notExistTextAnswer ( questions ) ) ) { answer = answerService . addDefaultTextAnswer ( question ) ; } else { answer = answerService . addDefaultAnswer ( answerType , question ) ; } String jsonData = JSONParser . convertObjectToJsonString ( answer ) ; return new ResponseEntity ( jsonData , HttpStatus . OK ) ; } @ ResponseBody @ RequestMapping ( value = { "//del-answer" } , method = RequestMethod . POST , produces = "text//plain;<seq2seq4repair_space>charset=UTF-8" ) public ResponseEntity < String > removeAnswer ( String hash , int questId , int answerId ) { } @ ResponseBody @ RequestMapping ( value = { "//save-answer" } , method = RequestMethod . POST , produces = "text//plain;<seq2seq4repair_space>charset=UTF-8" ) public ResponseEntity < String > saveAnswer ( int questId , int answerId , String text ) { } }

Fix:
AnswerType answerType = question . getType ( ) . getAnswerType ( ) ;