Program: 189285
Project: 189285
Buggy source:
@Override public WorkflowStep update(WorkflowStep workflowStep,Organization requestingOrganization) throws WorkflowStepNonOverrideableException {
  if (workflowStep.getOriginatingOrganization() != null && requestingOrganization.getId().equals(workflowStep.getOriginatingOrganization().getId())) {
    workflowStep=workflowStepRepo.findOne(workflowStep.getId());
    Organization originatingOrg=workflowStep.getOriginatingOrganization();
    if (workflowStep.getOverrideable() == false) {
      Set<WorkflowStep> derivativeWorkflowStepsToDelete=recursivelyReplaceDescendantStepsYieldingSetToDelete(originatingOrg,workflowStep);
      for (      WorkflowStep ws : derivativeWorkflowStepsToDelete) {
        workflowStepRepo.delete(ws);
      }
    }
    workflowStep=workflowStepRepo.save(workflowStep);
  }
 else   if (workflowStep.getOverrideable()) {
    WorkflowStep newWorkflowStep=workflowStepRepo.create(workflowStep.getName(),requestingOrganization,requestingOrganization.getPositionOfWorkflowStep(workflowStep),workflowStep);
    newWorkflowStep.setOriginatingWorkflowStep(workflowStep.getOriginatingWorkflowStep());
    newWorkflowStep.addContainedByOrganization(requestingOrganization);
    newWorkflowStep.setOriginatingOrganization(requestingOrganization);
    for (    FieldProfile fieldProfile : workflowStep.getFieldProfiles()) {
      fieldProfile.setOriginatingWorkflowStep(workflowStep);
      newWorkflowStep.addFieldProfile(fieldProfile);
    }
    requestingOrganization.removeWorkflowStep(workflowStepRepo.findOne(workflowStep.getId()));
    requestingOrganization.removeWorkflowStepOrder(workflowStep.getId());
    for (    Organization childOrg : requestingOrganization.getChildrenOrganizations()) {
      recursivelyReplaceWSIdsInOrders(childOrg,workflowStep,newWorkflowStep);
    }
    organizationRepo.save(requestingOrganization);
    return newWorkflowStep;
  }
 else {
    throw new WorkflowStepNonOverrideableException();
  }
  return workflowStep;
}

Fixed version (ground truth):
@Override public WorkflowStep update(WorkflowStep workflowStep,Organization requestingOrganization) throws WorkflowStepNonOverrideableException {
  if (workflowStep.getOriginatingOrganization() != null && requestingOrganization.getId().equals(workflowStep.getOriginatingOrganization().getId())) {
    Organization originatingOrg=workflowStep.getOriginatingOrganization();
    if (workflowStep.getOverrideable() == false) {
      Set<WorkflowStep> derivativeWorkflowStepsToDelete=recursivelyReplaceDescendantStepsYieldingSetToDelete(originatingOrg,workflowStep);
      for (      WorkflowStep ws : derivativeWorkflowStepsToDelete) {
        workflowStepRepo.delete(ws);
      }
    }
    workflowStep=workflowStepRepo.save(workflowStep);
  }
 else   if (workflowStep.getOverrideable()) {
    WorkflowStep newWorkflowStep=workflowStepRepo.create(workflowStep.getName(),requestingOrganization,requestingOrganization.getPositionOfWorkflowStep(workflowStep),workflowStep);
    newWorkflowStep.setOriginatingWorkflowStep(workflowStep.getOriginatingWorkflowStep());
    newWorkflowStep.addContainedByOrganization(requestingOrganization);
    newWorkflowStep.setOriginatingOrganization(requestingOrganization);
    for (    FieldProfile fieldProfile : workflowStep.getFieldProfiles()) {
      fieldProfile.setOriginatingWorkflowStep(workflowStep);
      newWorkflowStep.addFieldProfile(fieldProfile);
    }
    requestingOrganization.removeWorkflowStep(workflowStepRepo.findOne(workflowStep.getId()));
    requestingOrganization.removeWorkflowStepOrder(workflowStep.getId());
    for (    Organization childOrg : requestingOrganization.getChildrenOrganizations()) {
      recursivelyReplaceWSIdsInOrders(childOrg,workflowStep,newWorkflowStep);
    }
    organizationRepo.save(requestingOrganization);
    return newWorkflowStep;
  }
 else {
    throw new WorkflowStepNonOverrideableException();
  }
  return workflowStep;
}