Program: 5120
Project: 5120
Buggy source:
/** 
 * Add a schedule to an application.
 * @param applicationId the application id for which the schedule needs to be added
 * @param scheduleSpec the schedule specification
 * @throws NotFoundException when application is not found
 * @throws SchedulerException on an exception when updating the schedule
 * @throws BadRequestException if the program type is not workflow
 */
public void addSchedule(ApplicationId applicationId,ScheduleSpecification scheduleSpec) throws NotFoundException, SchedulerException, AlreadyExistsException, BadRequestException {
  ApplicationSpecification appSpec=store.getApplication(applicationId);
  if (appSpec == null) {
    throw new ApplicationNotFoundException(applicationId);
  }
  String scheduleName=scheduleSpec.getSchedule().getName();
  ScheduleSpecification existingScheduleSpec=appSpec.getSchedules().get(scheduleName);
  if (existingScheduleSpec != null) {
    throw new AlreadyExistsException(new ScheduleId(applicationId.getNamespace(),applicationId.getApplication(),scheduleName));
  }
  ProgramType programType=ProgramType.valueOfSchedulableType(scheduleSpec.getProgram().getProgramType());
  String programName=scheduleSpec.getProgram().getProgramName();
  ProgramId programId=applicationId.program(programType,programName);
  if (!programType.equals(ProgramType.WORKFLOW)) {
    throw new BadRequestException("String_Node_Str");
  }
  scheduler.schedule(programId,scheduleSpec.getProgram().getProgramType(),scheduleSpec.getSchedule(),scheduleSpec.getProperties());
  store.addSchedule(programId,scheduleSpec,false);
}

Fixed version (ground truth):
/** 
 * Add a schedule to an application.
 * @param applicationId the application id for which the schedule needs to be added
 * @param scheduleSpec the schedule specification
 * @throws NotFoundException when application is not found
 * @throws SchedulerException on an exception when updating the schedule
 * @throws BadRequestException if the program type is not workflow
 */
public void addSchedule(ApplicationId applicationId,ScheduleSpecification scheduleSpec) throws NotFoundException, SchedulerException, AlreadyExistsException, BadRequestException {
  ApplicationSpecification appSpec=store.getApplication(applicationId);
  if (appSpec == null) {
    throw new ApplicationNotFoundException(applicationId);
  }
  String scheduleName=scheduleSpec.getSchedule().getName();
  ScheduleSpecification existingScheduleSpec=appSpec.getSchedules().get(scheduleName);
  if (existingScheduleSpec != null) {
    throw new AlreadyExistsException(new ScheduleId(applicationId.getNamespace(),applicationId.getApplication(),scheduleName));
  }
  ProgramType programType=getSchedulableProgramType(scheduleSpec);
  String programName=scheduleSpec.getProgram().getProgramName();
  ProgramId programId=applicationId.program(programType,programName);
  if (!programType.equals(ProgramType.WORKFLOW)) {
    throw new BadRequestException("String_Node_Str");
  }
  try {
    scheduler.schedule(programId,scheduleSpec.getProgram().getProgramType(),scheduleSpec.getSchedule(),scheduleSpec.getProperties());
  }
 catch (  IllegalArgumentException e) {
    throw new BadRequestException(e);
  }
  store.addSchedule(programId,scheduleSpec,false);
}