Program: 5116
Project: 5116
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=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);
}

Fixed version (ground truth):
/** 
 * Update the schedule in an application.
 * @param applicationId the application containing the schedule
 * @param scheduleName the name of the schedule which needs to updated
 * @param scheduleUpdateDetail updated schedule details
 * @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,String scheduleName,ScheduleUpdateDetail scheduleUpdateDetail) throws NotFoundException, SchedulerException, AlreadyExistsException, BadRequestException {
  ApplicationSpecification appSpec=store.getApplication(applicationId);
  if (appSpec == null) {
    throw new ApplicationNotFoundException(applicationId);
  }
  ScheduleSpecification existingScheduleSpec=appSpec.getSchedules().get(scheduleName);
  if (existingScheduleSpec == null) {
    throw new NotFoundException(new ScheduleId(applicationId.getNamespace(),applicationId.getApplication(),scheduleName));
  }
  ProgramType programType=ProgramType.valueOfSchedulableType(existingScheduleSpec.getProgram().getProgramType());
  String programName=existingScheduleSpec.getProgram().getProgramName();
  ProgramId programId=applicationId.program(programType,programName);
  ScheduleSpecification updatedScheduleSpec=getUpdatedScheduleSpecification(existingScheduleSpec,scheduleUpdateDetail);
  try {
    scheduler.updateSchedule(programId,existingScheduleSpec.getProgram().getProgramType(),updatedScheduleSpec.getSchedule(),updatedScheduleSpec.getProperties());
  }
 catch (  IllegalArgumentException e) {
    throw new BadRequestException(e);
  }
  store.addSchedule(programId,updatedScheduleSpec,true);
}