Program: 188980
Project: 188980
Buggy source:
/** 
 * Separating out the launching of a new workflow. This way, we can eventually refactor this to the Workflow object.
 * @param options
 * @param config
 * @param params
 * @param metadata
 * @param workflowAccession
 * @return 
 */
public static ReturnValue launchNewWorkflow(OptionSet options,Map<String,String> config,String[] params,Metadata metadata,Integer workflowAccession,Integer workflowRunAccession){
  Log.info("String_Node_Str");
  ReturnValue ret=new ReturnValue();
  AbstractWorkflowDataModel dataModel;
  try {
    final WorkflowDataModelFactory factory=new WorkflowDataModelFactory(options,config,params,metadata);
    dataModel=factory.getWorkflowDataModel(workflowAccession,workflowRunAccession);
  }
 catch (  Exception e) {
    Log.fatal(e,e);
    ret.setExitStatus(ReturnValue.INVALIDARGUMENT);
    return ret;
  }
  Log.info("String_Node_Str");
  AbstractWorkflowEngine engine=WorkflowPlugin.getWorkflowEngine(dataModel);
  if (options.has("String_Node_Str")) {
    Log.stdout("String_Node_Str" + engine.getStatus((String)options.valueOf("String_Node_Str")));
    return new ReturnValue(ReturnValue.SUCCESS);
  }
  ReturnValue retPegasus=engine.launchWorkflow(dataModel);
  if (!dataModel.isMetadataWriteBack()) {
    return retPegasus;
  }
  Log.info("String_Node_Str");
  String wra=dataModel.getWorkflow_run_accession();
  if (wra == null || wra.isEmpty()) {
    return retPegasus;
  }
  int workflowrunId=Integer.parseInt(wra);
  int workflowrunaccession=metadata.get_workflow_run_accession(workflowrunId);
  String statusCmd=engine.getStatus();
  List<String> parentsLinkedToWR=new ArrayList<String>();
  if (options.has("String_Node_Str")) {
    List opts=options.valuesOf("String_Node_Str");
    for (    Object opt : opts) {
      String[] tokens=((String)opt).split("String_Node_Str");
      for (      String t : tokens) {
        parentsLinkedToWR.add(t);
      }
    }
  }
  WorkflowRun wr=null;
  for (  String parentLinkedToWR : parentsLinkedToWR) {
    try {
      metadata.linkWorkflowRunAndParent(workflowrunId,Integer.parseInt(parentLinkedToWR));
    }
 catch (    Exception e) {
      Log.error(e.getMessage());
    }
  }
  wr=metadata.getWorkflowRun(workflowrunaccession);
  if (retPegasus.getProcessExitStatus() != ReturnValue.SUCCESS || statusCmd == null) {
    metadata.update_workflow_run(workflowrunId,dataModel.getTags().get("String_Node_Str"),dataModel.getTags().get("String_Node_Str"),"String_Node_Str",statusCmd,dataModel.getWorkflowBundleDir(),"String_Node_Str","String_Node_Str",wr.getHost(),0,0,retPegasus.getStderr(),retPegasus.getStdout(),engine.getClass().getSimpleName());
    return retPegasus;
  }
 else {
    metadata.update_workflow_run(workflowrunId,dataModel.getTags().get("String_Node_Str"),dataModel.getTags().get("String_Node_Str"),"String_Node_Str",statusCmd,dataModel.getWorkflowBundleDir(),"String_Node_Str","String_Node_Str",wr.getHost(),0,0,retPegasus.getStderr(),retPegasus.getStdout(),engine.getClass().getSimpleName());
    return ret;
  }
}

Fixed version (ground truth):
/** 
 * Separating out the launching of a new workflow. This way, we can eventually refactor this to the Workflow object.
 * @param options
 * @param config
 * @param params
 * @param metadata
 * @param workflowAccession
 * @return 
 */
public static ReturnValue launchNewWorkflow(OptionSet options,Map<String,String> config,String[] params,Metadata metadata,Integer workflowAccession,Integer workflowRunAccession){
  Log.info("String_Node_Str");
  ReturnValue ret=new ReturnValue();
  AbstractWorkflowDataModel dataModel;
  try {
    final WorkflowDataModelFactory factory=new WorkflowDataModelFactory(options,config,params,metadata);
    dataModel=factory.getWorkflowDataModel(workflowAccession,workflowRunAccession);
  }
 catch (  Exception e) {
    Log.fatal(e,e);
    ret.setExitStatus(ReturnValue.INVALIDARGUMENT);
    return ret;
  }
  Log.info("String_Node_Str");
  AbstractWorkflowEngine engine=WorkflowPlugin.getWorkflowEngine(dataModel);
  if (options.has("String_Node_Str")) {
    Log.stdout("String_Node_Str" + engine.getStatus((String)options.valueOf("String_Node_Str")));
    return new ReturnValue(ReturnValue.SUCCESS);
  }
  ReturnValue retPegasus=engine.launchWorkflow(dataModel);
  if (!dataModel.isMetadataWriteBack()) {
    return retPegasus;
  }
  Log.info("String_Node_Str");
  String wra=dataModel.getWorkflow_run_accession();
  if (wra == null || wra.isEmpty()) {
    return retPegasus;
  }
  int workflowrunaccession=Integer.parseInt(wra);
  int workflowrunId=metadata.get_workflow_run_id(workflowrunaccession);
  String statusCmd=engine.getStatus();
  List<String> parentsLinkedToWR=new ArrayList<String>();
  if (options.has("String_Node_Str")) {
    List opts=options.valuesOf("String_Node_Str");
    for (    Object opt : opts) {
      String[] tokens=((String)opt).split("String_Node_Str");
      for (      String t : tokens) {
        parentsLinkedToWR.add(t);
      }
    }
  }
  WorkflowRun wr=null;
  for (  String parentLinkedToWR : parentsLinkedToWR) {
    try {
      metadata.linkWorkflowRunAndParent(workflowrunId,Integer.parseInt(parentLinkedToWR));
    }
 catch (    Exception e) {
      Log.error(e.getMessage());
    }
  }
  wr=metadata.getWorkflowRun(workflowrunaccession);
  if (retPegasus.getProcessExitStatus() != ReturnValue.SUCCESS || statusCmd == null) {
    metadata.update_workflow_run(workflowrunId,dataModel.getTags().get("String_Node_Str"),dataModel.getTags().get("String_Node_Str"),"String_Node_Str",statusCmd,dataModel.getWorkflowBundleDir(),"String_Node_Str","String_Node_Str",wr.getHost(),0,0,retPegasus.getStderr(),retPegasus.getStdout(),engine.getClass().getSimpleName());
    return retPegasus;
  }
 else {
    String status=dataModel.isWait() ? "String_Node_Str" : "String_Node_Str";
    metadata.update_workflow_run(workflowrunId,dataModel.getTags().get("String_Node_Str"),dataModel.getTags().get("String_Node_Str"),status,statusCmd,dataModel.getWorkflowBundleDir(),"String_Node_Str","String_Node_Str",wr.getHost(),0,0,retPegasus.getStderr(),retPegasus.getStdout(),engine.getClass().getSimpleName());
    return ret;
  }
}