Program: 141197
Project: 141197
Buggy source:
/** 
 * Search dependency between steps.
 * @throws EoulsanException if an error occurs while search dependencies
 */
private void searchDependencies() throws EoulsanException {
  final Set<DataFormat> dataFormatsFromDesign=getDesignDataFormats();
  final List<CommandWorkflowStep> steps=this.steps;
  for (int i=steps.size() - 1; i >= 0; i--) {
    final CommandWorkflowStep step=steps.get(i);
    if (step.getInputDataFormats().isEmpty() && i > 0)     step.addDependency(steps.get(i - 1));
    for (    DataFormat format : step.getInputDataFormats()) {
      if (step.isDependencySet(format))       continue;
      boolean found=false;
      for (int j=i - 1; j >= 0; j--) {
        final CommandWorkflowStep stepTested=steps.get(j);
        if ((stepTested.getType() == StepType.STANDARD_STEP || stepTested.getType() == StepType.GENERATOR_STEP) && stepTested.getOutputDataFormats().contains(format)) {
          addDependency(step,format,stepTested);
          found=true;
          break;
        }
        if (stepTested.getType() == StepType.DESIGN_STEP && dataFormatsFromDesign.contains(format)) {
          addDependency(step,format,stepTested);
          found=true;
          break;
        }
      }
      if (!found) {
        if (format.isGenerator()) {
          if (!this.generatorAdded.containsKey(format)) {
            final CommandWorkflowStep generatorStep=new CommandWorkflowStep(this,format);
            generatorStep.configure();
            addStep(indexOfStep(getCheckerStep()) + 1,generatorStep);
            this.generatorAdded.put(format,generatorStep);
            searchDependencies();
            return;
          }
 else {
            if (step.getType() == StepType.GENERATOR_STEP) {
              Collections.swap(this.steps,indexOfStep(step),indexOfStep(this.generatorAdded.get(format)));
              searchDependencies();
              return;
            }
 else             throw new EoulsanException("String_Node_Str" + format.getName() + "String_Node_Str"+ step.getId()+ "String_Node_Str");
          }
        }
 else         throw new EoulsanException("String_Node_Str" + format.getName() + "String_Node_Str"+ step.getId()+ "String_Node_Str");
      }
    }
  }
  this.generatorAdded.clear();
  final List<CommandWorkflowStep> terminalSteps=Lists.newArrayList();
  for (  CommandWorkflowStep step : this.steps) {
    for (    CommandWorkflowStep terminalStep : terminalSteps)     step.addDependency(terminalStep);
    if (step.isTerminalStep())     terminalSteps.add(step);
  }
  for (  CommandWorkflowStep step : Lists.newArrayList(this.steps)) {
    if (step.isCopyResultsToOutput() && !step.getStepWorkingDir().equals(getOutputDir())) {
      CommandWorkflowStep newStep=newOutputFormatCopyStep(this,step.getId(),getOutputDir(),step.getOutputDataFormats());
      addStep(indexOfStep(step) + 1,newStep);
      for (      DataFormat format : step.getOutputDataFormats())       newStep.addDependency(format,step);
    }
  }
}

Fixed version (ground truth):
/** 
 * Search dependency between steps.
 * @throws EoulsanException if an error occurs while search dependencies
 */
private void searchDependencies() throws EoulsanException {
  final Set<DataFormat> dataFormatsFromDesign=getDesignDataFormats();
  final List<CommandWorkflowStep> steps=this.steps;
  for (int i=steps.size() - 1; i >= 0; i--) {
    final CommandWorkflowStep step=steps.get(i);
    if (step.getInputDataFormats().isEmpty() && i > 0)     step.addDependency(steps.get(i - 1));
    for (    DataFormat format : step.getInputDataFormats()) {
      if (step.isDependencySet(format))       continue;
      boolean found=false;
      for (int j=i - 1; j >= 0; j--) {
        final CommandWorkflowStep stepTested=steps.get(j);
        if ((stepTested.getType() == StepType.STANDARD_STEP || stepTested.getType() == StepType.GENERATOR_STEP) && stepTested.getOutputDataFormats().contains(format)) {
          addDependency(step,format,stepTested);
          found=true;
          break;
        }
        if (stepTested.getType() == StepType.DESIGN_STEP && dataFormatsFromDesign.contains(format)) {
          addDependency(step,format,stepTested);
          found=true;
          break;
        }
      }
      if (!found) {
        if (format.isGenerator()) {
          if (!this.generatorAdded.containsKey(format)) {
            final CommandWorkflowStep generatorStep=new CommandWorkflowStep(this,format);
            generatorStep.configure();
            addStep(indexOfStep(getCheckerStep()) + 1,generatorStep);
            this.generatorAdded.put(format,generatorStep);
            searchDependencies();
            return;
          }
          if (step.getType() == StepType.GENERATOR_STEP) {
            Collections.swap(this.steps,indexOfStep(step),indexOfStep(this.generatorAdded.get(format)));
            searchDependencies();
            return;
          }
          throw new EoulsanException("String_Node_Str" + format.getName() + "String_Node_Str"+ step.getId()+ "String_Node_Str");
        }
      }
    }
  }
  this.generatorAdded.clear();
  final List<CommandWorkflowStep> terminalSteps=Lists.newArrayList();
  for (  CommandWorkflowStep step : this.steps) {
    for (    CommandWorkflowStep terminalStep : terminalSteps)     step.addDependency(terminalStep);
    if (step.isTerminalStep())     terminalSteps.add(step);
  }
  for (  CommandWorkflowStep step : Lists.newArrayList(this.steps)) {
    if (step.isCopyResultsToOutput() && !step.getStepWorkingDir().equals(getOutputDir())) {
      CommandWorkflowStep newStep=newOutputFormatCopyStep(this,step.getId(),step.getOutputDataFormats());
      addStep(indexOfStep(step) + 1,newStep);
      for (      DataFormat format : step.getOutputDataFormats())       newStep.addDependency(format,step);
    }
  }
}