Program: 62735
Project: 62735
Buggy source:
@Override public ActionResult execute() throws EntityDoesNotExistException {
  String courseId=getRequestParamValue(Const.ParamsNames.COURSE_ID);
  Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID,courseId);
  String studentEmail=getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL);
  Assumption.assertPostParamNotNull(Const.ParamsNames.STUDENT_EMAIL,studentEmail);
  InstructorAttributes instructor=logic.getInstructorForGoogleId(courseId,account.googleId);
  new GateKeeper().verifyAccessible(instructor,logic.getCourse(courseId),Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
  boolean hasSection=logic.hasIndicatedSections(courseId);
  StudentAttributes student=logic.getStudentForEmail(courseId,studentEmail);
  if (student == null) {
    return redirectWithError(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_EDIT,"String_Node_Str" + studentEmail + "String_Node_Str"+ "String_Node_Str"+ courseId+ "String_Node_Str",courseId);
  }
  student.name=getRequestParamValue(Const.ParamsNames.STUDENT_NAME);
  student.email=getRequestParamValue(Const.ParamsNames.NEW_STUDENT_EMAIL);
  student.team=getRequestParamValue(Const.ParamsNames.TEAM_NAME);
  student.section=getRequestParamValue(Const.ParamsNames.SECTION_NAME);
  student.comments=getRequestParamValue(Const.ParamsNames.COMMENTS);
  student.name=Sanitizer.sanitizeName(student.name);
  student.email=Sanitizer.sanitizeEmail(student.email);
  student.team=Sanitizer.sanitizeName(student.team);
  student.section=Sanitizer.sanitizeName(student.section);
  student.comments=Sanitizer.sanitizeTextField(student.comments);
  try {
    StudentAttributes originalStudentAttribute=logic.getStudentForEmail(courseId,studentEmail);
    student.updateWithExistingRecord(originalStudentAttribute);
    boolean hasSectionChanged=student.hasSectionChanged(originalStudentAttribute);
    boolean hasTeamChanged=student.hasSectionChanged(originalStudentAttribute);
    if (hasSectionChanged) {
      logic.validateSectionsAndTeams(Arrays.asList(student),courseId);
    }
 else     if (hasTeamChanged) {
      logic.validateTeams(Arrays.asList(student),courseId);
    }
    logic.updateStudent(studentEmail,student);
    statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_EDITED,StatusMessageColor.SUCCESS));
    statusToAdmin="String_Node_Str" + studentEmail + "String_Node_Str"+ "String_Node_Str"+ courseId+ "String_Node_Str"+ "String_Node_Str"+ student.email+ "String_Node_Str"+ student.team+ "String_Node_Str"+ "String_Node_Str"+ student.comments;
    RedirectResult result=createRedirectResult(Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE);
    result.addResponseParam(Const.ParamsNames.COURSE_ID,courseId);
    return result;
  }
 catch (  InvalidParametersException|EnrollException e) {
    setStatusForException(e);
    String newEmail=student.email;
    student.email=studentEmail;
    InstructorCourseStudentDetailsEditPageData data=new InstructorCourseStudentDetailsEditPageData(account,student,newEmail,hasSection);
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_STUDENT_EDIT,data);
  }
}

Fixed version (ground truth):
@Override public ActionResult execute() throws EntityDoesNotExistException {
  String courseId=getRequestParamValue(Const.ParamsNames.COURSE_ID);
  Assumption.assertPostParamNotNull(Const.ParamsNames.COURSE_ID,courseId);
  String studentEmail=getRequestParamValue(Const.ParamsNames.STUDENT_EMAIL);
  Assumption.assertPostParamNotNull(Const.ParamsNames.STUDENT_EMAIL,studentEmail);
  InstructorAttributes instructor=logic.getInstructorForGoogleId(courseId,account.googleId);
  new GateKeeper().verifyAccessible(instructor,logic.getCourse(courseId),Const.ParamsNames.INSTRUCTOR_PERMISSION_MODIFY_STUDENT);
  boolean hasSection=logic.hasIndicatedSections(courseId);
  StudentAttributes student=logic.getStudentForEmail(courseId,studentEmail);
  if (student == null) {
    return redirectWithError(Const.StatusMessages.STUDENT_NOT_FOUND_FOR_EDIT,"String_Node_Str" + studentEmail + "String_Node_Str"+ "String_Node_Str"+ courseId+ "String_Node_Str",courseId);
  }
  student.name=getRequestParamValue(Const.ParamsNames.STUDENT_NAME);
  student.email=getRequestParamValue(Const.ParamsNames.NEW_STUDENT_EMAIL);
  student.team=getRequestParamValue(Const.ParamsNames.TEAM_NAME);
  student.section=getRequestParamValue(Const.ParamsNames.SECTION_NAME);
  student.comments=getRequestParamValue(Const.ParamsNames.COMMENTS);
  student.name=Sanitizer.sanitizeName(student.name);
  student.email=Sanitizer.sanitizeEmail(student.email);
  student.team=Sanitizer.sanitizeName(student.team);
  student.section=Sanitizer.sanitizeName(student.section);
  student.comments=Sanitizer.sanitizeTextField(student.comments);
  try {
    StudentAttributes originalStudentAttribute=logic.getStudentForEmail(courseId,studentEmail);
    student.updateWithExistingRecord(originalStudentAttribute);
    boolean isSectionChanged=student.isSectionChanged(originalStudentAttribute);
    boolean isTeamChanged=student.isTeamChanged(originalStudentAttribute);
    if (isSectionChanged) {
      logic.validateSectionsAndTeams(Arrays.asList(student),courseId);
    }
 else     if (isTeamChanged) {
      logic.validateTeams(Arrays.asList(student),courseId);
    }
    logic.updateStudent(studentEmail,student);
    statusToUser.add(new StatusMessage(Const.StatusMessages.STUDENT_EDITED,StatusMessageColor.SUCCESS));
    statusToAdmin="String_Node_Str" + studentEmail + "String_Node_Str"+ "String_Node_Str"+ courseId+ "String_Node_Str"+ "String_Node_Str"+ student.email+ "String_Node_Str"+ student.team+ "String_Node_Str"+ "String_Node_Str"+ student.comments;
    RedirectResult result=createRedirectResult(Const.ActionURIs.INSTRUCTOR_COURSE_DETAILS_PAGE);
    result.addResponseParam(Const.ParamsNames.COURSE_ID,courseId);
    return result;
  }
 catch (  InvalidParametersException|EnrollException e) {
    setStatusForException(e);
    String newEmail=student.email;
    student.email=studentEmail;
    InstructorCourseStudentDetailsEditPageData data=new InstructorCourseStudentDetailsEditPageData(account,student,newEmail,hasSection);
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_COURSE_STUDENT_EDIT,data);
  }
}