Program: 5121
Project: 5121
Buggy source:
/** 
 * Update the schedule in an application.
 * @param applicationId the application containing the schedule
 * @param scheduleSpecUpdate updated schedule specification
 * @throws NotFoundException when application is not found
 * @throws SchedulerException on an exception when updating the schedule
 * @throws BadRequestException when existing schedule type does not match the updated schedule type
 */
public void updateSchedule(ApplicationId applicationId,ScheduleSpecification scheduleSpecUpdate) throws NotFoundException, SchedulerException, AlreadyExistsException, BadRequestException {
  ApplicationSpecification appSpec=store.getApplication(applicationId);
  if (appSpec == null) {
    throw new ApplicationNotFoundException(applicationId);
  }
  String scheduleName=scheduleSpecUpdate.getSchedule().getName();
  ScheduleSpecification existingScheduleSpec=appSpec.getSchedules().get(scheduleName);
  if (existingScheduleSpec == null) {
    throw new NotFoundException(new ScheduleId(applicationId.getNamespace(),applicationId.getApplication(),scheduleName));
  }
  ScheduleType existingType=ScheduleType.fromSchedule(existingScheduleSpec.getSchedule());
  ScheduleType newType=ScheduleType.fromSchedule(scheduleSpecUpdate.getSchedule());
  if (!existingType.equals(newType)) {
    throw new BadRequestException(String.format("String_Node_Str",newType,existingType));
  }
  ProgramType existingProgramType=ProgramType.valueOfSchedulableType(existingScheduleSpec.getProgram().getProgramType());
  ProgramType programType=ProgramType.valueOfSchedulableType(scheduleSpecUpdate.getProgram().getProgramType());
  String programName=scheduleSpecUpdate.getProgram().getProgramName();
  ProgramId programId=applicationId.program(programType,programName);
  if (!existingProgramType.equals(programType)) {
    throw new BadRequestException(String.format("String_Node_Str",programType,existingProgramType));
  }
  scheduler.updateSchedule(programId,scheduleSpecUpdate.getProgram().getProgramType(),scheduleSpecUpdate.getSchedule(),scheduleSpecUpdate.getProperties());
  store.addSchedule(programId,scheduleSpecUpdate,true);
}

Fixed version (ground truth):
/** 
 * Update the schedule in an application.
 * @param applicationId the application containing the schedule
 * @param scheduleSpecUpdate updated schedule specification
 * @throws NotFoundException when application is not found
 * @throws SchedulerException on an exception when updating the schedule
 * @throws BadRequestException when existing schedule type does not match the updated schedule type
 */
public void updateSchedule(ApplicationId applicationId,ScheduleSpecification scheduleSpecUpdate) throws NotFoundException, SchedulerException, AlreadyExistsException, BadRequestException {
  ApplicationSpecification appSpec=store.getApplication(applicationId);
  if (appSpec == null) {
    throw new ApplicationNotFoundException(applicationId);
  }
  String scheduleName=scheduleSpecUpdate.getSchedule().getName();
  ScheduleSpecification existingScheduleSpec=appSpec.getSchedules().get(scheduleName);
  if (existingScheduleSpec == null) {
    throw new NotFoundException(new ScheduleId(applicationId.getNamespace(),applicationId.getApplication(),scheduleName));
  }
  ScheduleType existingType=ScheduleType.fromSchedule(existingScheduleSpec.getSchedule());
  ScheduleType newType=ScheduleType.fromSchedule(scheduleSpecUpdate.getSchedule());
  if (!existingType.equals(newType)) {
    throw new BadRequestException(String.format("String_Node_Str",newType,existingType));
  }
  ProgramType existingProgramType=ProgramType.valueOfSchedulableType(existingScheduleSpec.getProgram().getProgramType());
  ProgramType programType=getSchedulableProgramType(scheduleSpecUpdate);
  String programName=scheduleSpecUpdate.getProgram().getProgramName();
  ProgramId programId=applicationId.program(programType,programName);
  if (!existingProgramType.equals(programType)) {
    throw new BadRequestException(String.format("String_Node_Str",programType,existingProgramType));
  }
  try {
    scheduler.updateSchedule(programId,scheduleSpecUpdate.getProgram().getProgramType(),scheduleSpecUpdate.getSchedule(),scheduleSpecUpdate.getProperties());
  }
 catch (  IllegalArgumentException e) {
    throw new BadRequestException(e);
  }
  store.addSchedule(programId,scheduleSpecUpdate,true);
}