Program: 51964
Project: 51964
Buggy source:
@Override public WorkflowActionConfig processOutcome(Context c,EPerson user,Workflow workflow,Step currentStep,WorkflowActionConfig currentActionConfig,ActionResult currentOutcome,XmlWorkflowItem wfi,boolean enteredNewStep) throws IOException, AuthorizeException, SQLException, WorkflowException {
  if (currentOutcome.getType() == ActionResult.TYPE.TYPE_PAGE || currentOutcome.getType() == ActionResult.TYPE.TYPE_ERROR) {
    c.restoreAuthSystemState();
    return currentActionConfig;
  }
 else   if (currentOutcome.getType() == ActionResult.TYPE.TYPE_CANCEL || currentOutcome.getType() == ActionResult.TYPE.TYPE_SUBMISSION_PAGE) {
    c.restoreAuthSystemState();
    return null;
  }
 else   if (currentOutcome.getType() == ActionResult.TYPE.TYPE_OUTCOME) {
    Step nextStep=null;
    WorkflowActionConfig nextActionConfig=null;
    try {
      if (currentOutcome.getResult() == ActionResult.OUTCOME_COMPLETE) {
        nextActionConfig=currentStep.getNextAction(currentActionConfig);
      }
      if (nextActionConfig != null) {
        nextStep=currentStep;
        nextActionConfig.getProcessingAction().activate(c,wfi);
        if (nextActionConfig.requiresUI() && !enteredNewStep) {
          createOwnedTask(c,wfi,currentStep,nextActionConfig,user);
          return nextActionConfig;
        }
 else         if (nextActionConfig.requiresUI() && enteredNewStep) {
          c.restoreAuthSystemState();
          return null;
        }
 else {
          ActionResult newOutcome=nextActionConfig.getProcessingAction().execute(c,wfi,currentStep,null);
          return processOutcome(c,user,workflow,currentStep,nextActionConfig,newOutcome,wfi,enteredNewStep);
        }
      }
 else       if (enteredNewStep) {
        nextStep=workflow.getNextStep(c,wfi,currentStep,currentOutcome.getResult());
        c.turnOffAuthorisationSystem();
        nextActionConfig=processNextStep(c,user,workflow,currentOutcome,wfi,nextStep);
        if (nextActionConfig == null || nextActionConfig.requiresUI()) {
          return null;
        }
 else {
          return nextActionConfig;
        }
      }
 else {
        ClaimedTask task=claimedTaskService.findByWorkflowIdAndEPerson(c,wfi,user);
        workflowRequirementsService.addFinishedUser(c,wfi,user);
        c.turnOffAuthorisationSystem();
        if ((currentStep.isFinished(c,wfi) && currentOutcome.getResult() == ActionResult.OUTCOME_COMPLETE) || currentOutcome.getResult() != ActionResult.OUTCOME_COMPLETE) {
          workflowRequirementsService.clearInProgressUsers(c,wfi);
          deleteAllTasks(c,wfi);
          nextStep=workflow.getNextStep(c,wfi,currentStep,currentOutcome.getResult());
          nextActionConfig=processNextStep(c,user,workflow,currentOutcome,wfi,nextStep);
          if (nextActionConfig == null || nextActionConfig.requiresUI()) {
            return null;
          }
 else {
            return nextActionConfig;
          }
        }
 else {
          deleteClaimedTask(c,wfi,task);
          c.restoreAuthSystemState();
          nextStep=currentStep;
          nextActionConfig=currentActionConfig;
          return null;
        }
      }
    }
 catch (    Exception e) {
      log.error("String_Node_Str",e);
      e.printStackTrace();
    }
 finally {
      if ((nextStep != null && nextActionConfig != null) || wfi.getItem().isArchived()) {
        logWorkflowEvent(c,currentStep.getWorkflow().getID(),currentStep.getId(),currentActionConfig.getId(),wfi,user,nextStep,nextActionConfig);
      }
    }
  }
  log.error(LogManager.getHeader(c,"String_Node_Str","String_Node_Str" + wfi.getID()));
  throw new WorkflowException("String_Node_Str");
}

Fixed version (ground truth):
@Override public WorkflowActionConfig processOutcome(Context c,EPerson user,Workflow workflow,Step currentStep,WorkflowActionConfig currentActionConfig,ActionResult currentOutcome,XmlWorkflowItem wfi,boolean enteredNewStep) throws IOException, AuthorizeException, SQLException, WorkflowException {
  if (currentOutcome.getType() == ActionResult.TYPE.TYPE_PAGE || currentOutcome.getType() == ActionResult.TYPE.TYPE_ERROR) {
    c.restoreAuthSystemState();
    return currentActionConfig;
  }
 else   if (currentOutcome.getType() == ActionResult.TYPE.TYPE_CANCEL || currentOutcome.getType() == ActionResult.TYPE.TYPE_SUBMISSION_PAGE) {
    c.restoreAuthSystemState();
    return null;
  }
 else   if (currentOutcome.getType() == ActionResult.TYPE.TYPE_OUTCOME) {
    Step nextStep=null;
    WorkflowActionConfig nextActionConfig=null;
    try {
      if (currentOutcome.getResult() == ActionResult.OUTCOME_COMPLETE) {
        nextActionConfig=currentStep.getNextAction(currentActionConfig);
      }
      if (nextActionConfig != null) {
        nextStep=currentStep;
        nextActionConfig.getProcessingAction().activate(c,wfi);
        if (nextActionConfig.requiresUI() && !enteredNewStep) {
          createOwnedTask(c,wfi,currentStep,nextActionConfig,user);
          return nextActionConfig;
        }
 else         if (nextActionConfig.requiresUI() && enteredNewStep) {
          c.restoreAuthSystemState();
          return null;
        }
 else {
          ActionResult newOutcome=nextActionConfig.getProcessingAction().execute(c,wfi,currentStep,null);
          return processOutcome(c,user,workflow,currentStep,nextActionConfig,newOutcome,wfi,enteredNewStep);
        }
      }
 else       if (enteredNewStep) {
        nextStep=workflow.getNextStep(c,wfi,currentStep,currentOutcome.getResult());
        c.turnOffAuthorisationSystem();
        nextActionConfig=processNextStep(c,user,workflow,currentOutcome,wfi,nextStep);
        if (nextActionConfig == null || nextActionConfig.requiresUI()) {
          return null;
        }
 else {
          return nextActionConfig;
        }
      }
 else {
        ClaimedTask task=claimedTaskService.findByWorkflowIdAndEPerson(c,wfi,user);
        workflowRequirementsService.addFinishedUser(c,wfi,user);
        c.turnOffAuthorisationSystem();
        if ((currentStep.isFinished(c,wfi) && currentOutcome.getResult() == ActionResult.OUTCOME_COMPLETE) || currentOutcome.getResult() != ActionResult.OUTCOME_COMPLETE) {
          workflowRequirementsService.clearInProgressUsers(c,wfi);
          deleteAllTasks(c,wfi);
          nextStep=workflow.getNextStep(c,wfi,currentStep,currentOutcome.getResult());
          nextActionConfig=processNextStep(c,user,workflow,currentOutcome,wfi,nextStep);
          if (nextActionConfig == null || nextActionConfig.requiresUI()) {
            return null;
          }
 else {
            return nextActionConfig;
          }
        }
 else {
          deleteClaimedTask(c,wfi,task);
          c.restoreAuthSystemState();
          nextStep=currentStep;
          nextActionConfig=currentActionConfig;
          return null;
        }
      }
    }
 catch (    Exception e) {
      log.error("String_Node_Str",e);
      e.printStackTrace();
    }
 finally {
      if ((nextStep != null && currentStep != null && nextActionConfig != null) || (wfi.getItem().isArchived() && currentStep != null)) {
        logWorkflowEvent(c,currentStep.getWorkflow().getID(),currentStep.getId(),currentActionConfig.getId(),wfi,user,nextStep,nextActionConfig);
      }
    }
  }
  log.error(LogManager.getHeader(c,"String_Node_Str","String_Node_Str" + wfi.getID()));
  throw new WorkflowException("String_Node_Str");
}