Program: 188869
Project: 188869
Buggy source:
private void preProcessMetadata(){
  if (optionHasOneOf(new String[]{"String_Node_Str","String_Node_Str"})) {
    Log.debug("String_Node_Str");
    return;
  }
  Map<String,String> settings=ConfigTools.getSettings();
  if (optionHasOneOf(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"})) {
    String user=options.valueOf("String_Node_Str").toString();
    String pass=options.valueOf("String_Node_Str").toString();
    String connection=options.valueOf("String_Node_Str").toString();
    try {
      meta=new MetadataDB(connection,user,pass);
    }
 catch (    SQLException e) {
      throw new RuntimeException(e);
    }
  }
 else {
    meta=MetadataFactory.get(settings);
  }
  int workflowRunId=0;
  int workflowRunAccession=0;
  ArrayList<Integer> parentIDs=new ArrayList<>();
  processingIDFiles=new ArrayList<>();
  ArrayList<Integer> parentAccessions=new ArrayList<>();
  processingAccessionFiles=new ArrayList<>();
  int ancestorWorkflowRunAccession=0;
  if (options.has("String_Node_Str")) {
    String outputFile=(String)options.valueOf("String_Node_Str");
    File file=new File(outputFile);
    try {
      if (file.exists() && file.canRead()) {
        String readFileToString=FileUtils.readFileToString(file).trim();
        try {
          int processingAccessionFromFile=Integer.valueOf(readFileToString);
          Processing proc=meta.getProcessing(processingAccessionFromFile);
          if (proc != null) {
            if (proc.getStatus().equals(ProcessingStatus.success)) {
              Log.error("String_Node_Str");
              System.exit(ReturnValue.SUCCESS);
            }
          }
        }
 catch (        NumberFormatException|NotFoundException ne) {
          Log.error("String_Node_Str");
        }
        Log.error("String_Node_Str");
      }
      if ((file.exists() || file.createNewFile()) && file.canWrite()) {
        processingAccessionFileCheck=file;
      }
 else {
        Log.error("String_Node_Str");
        System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
      }
    }
 catch (    IOException e) {
      Log.error("String_Node_Str" + e.getMessage());
      System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
    }
  }
  if (options.has("String_Node_Str")) {
    workflowRunId=meta.add_workflow_run((Integer)options.valueOf("String_Node_Str"));
    workflowRunAccession=meta.get_workflow_run_accession(workflowRunId);
    for (    String outputFile : (List<String>)options.valuesOf("String_Node_Str")) {
      File file=new File(outputFile);
      try {
        if ((file.exists() || file.createNewFile()) && file.canWrite()) {
          int maxTries=(Integer)options.valueOf("String_Node_Str");
          for (int i=0; i < maxTries; i++) {
            if (LockingFileTools.lockAndAppend(file,workflowRunAccession + System.getProperty("String_Node_Str"))) {
              break;
            }
 else             if (i < maxTries) {
              ProcessTools.sleep((Integer)options.valueOf("String_Node_Str"));
            }
 else {
              ReturnValue retval=new ReturnValue();
              retval.printAndAppendtoStderr("String_Node_Str");
              retval.setExitStatus(ReturnValue.METADATAINVALIDIDCHAIN);
              meta.update_processing_event(workflowRunAccession,retval);
              meta.update_processing_status(workflowRunAccession,ProcessingStatus.failed);
              System.exit(retval.getExitStatus());
            }
          }
        }
 else {
          Log.error("String_Node_Str");
          System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
        }
      }
 catch (      IOException e) {
        Log.error("String_Node_Str" + e.getMessage());
        System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
      }
      break;
    }
  }
  List<Integer> workflowRunAccessions=(List<Integer>)options.valuesOf("String_Node_Str");
  if (workflowRunAccessions.size() == 1) {
    workflowRunAccession=workflowRunAccessions.get(0);
  }
  for (  Integer parent : (List<Integer>)options.valuesOf("String_Node_Str")) {
    parentIDs.add(parent);
  }
  for (  String file : (List<String>)options.valuesOf("String_Node_Str")) {
    try {
      BufferedReader r;
      String line;
      r=new BufferedReader(new FileReader(file));
      while ((line=r.readLine()) != null) {
        try {
          parentIDs.add(Integer.parseInt(line));
        }
 catch (        NumberFormatException ex) {
          Log.error("String_Node_Str" + line + "String_Node_Str");
          System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
        }
      }
      r.close();
    }
 catch (    Exception e) {
      Log.error("String_Node_Str" + e.getMessage());
      System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
    }
  }
  for (  Integer parent : (List<Integer>)options.valuesOf("String_Node_Str")) {
    parentAccessions.add(parent);
  }
  for (  String file : (List<String>)options.valuesOf("String_Node_Str")) {
    try {
      BufferedReader r;
      String line;
      r=new BufferedReader(new FileReader(file));
      while ((line=r.readLine()) != null) {
        try {
          parentAccessions.add(Integer.parseInt(line));
        }
 catch (        NumberFormatException ex) {
          Log.error("String_Node_Str" + line + "String_Node_Str");
          System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
        }
      }
      r.close();
    }
 catch (    Exception e) {
      Log.error("String_Node_Str" + e.getMessage());
      System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
    }
  }
  for (  Integer accession : (List<Integer>)options.valuesOf("String_Node_Str")) {
    ancestorWorkflowRunAccession=accession;
  }
  for (  String file : (List<String>)options.valuesOf("String_Node_Str")) {
    try {
      BufferedReader r;
      String line;
      r=new BufferedReader(new FileReader(file));
      while ((line=r.readLine()) != null) {
        try {
          ancestorWorkflowRunAccession=Integer.parseInt(line);
        }
 catch (        NumberFormatException ex) {
          Log.error("String_Node_Str" + line + "String_Node_Str");
          System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
        }
      }
      r.close();
    }
 catch (    Exception e) {
      Log.error("String_Node_Str" + e.getMessage());
      System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
    }
  }
  for (  String outputFile : (List<String>)options.valuesOf("String_Node_Str")) {
    File file=new File(outputFile);
    try {
      if ((file.exists() || file.createNewFile()) && file.canWrite()) {
        processingIDFiles.add(file);
      }
 else {
        Log.error("String_Node_Str");
        System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
      }
    }
 catch (    IOException e) {
      Log.error("String_Node_Str" + e.getMessage());
      System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
    }
  }
  for (  String outputFile : (List<String>)options.valuesOf("String_Node_Str")) {
    File file=new File(outputFile);
    try {
      if ((file.exists() || file.createNewFile()) && file.canWrite()) {
        processingAccessionFiles.add(file);
      }
 else {
        Log.error("String_Node_Str");
        System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
      }
    }
 catch (    IOException e) {
      Log.error("String_Node_Str" + e.getMessage());
      System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
    }
  }
  processingAccession=0;
  if (meta != null) {
    int[] parents=new int[parentIDs.size()];
    for (int i=0; i < parentIDs.size(); i++) {
      parents[i]=parentIDs.get(i);
    }
    int[] parentAccessionsArray=new int[parentAccessions.size()];
    for (int i=0; i < parentAccessions.size(); i++) {
      parentAccessionsArray[i]=parentAccessions.get(i);
    }
    ReturnValue metaret;
    if (parentAccessionsArray.length > 0) {
      metaret=meta.add_empty_processing_event_by_parent_accession(parentAccessionsArray);
      if (metaret.getExitStatus() == ReturnValue.SUCCESS) {
        processingID=metaret.getReturnValue();
        processingAccession=meta.mapProcessingIdToAccession(processingID);
        printAndAppendtoStdout("String_Node_Str" + processingAccession);
      }
 else {
        printAndAppendtoStderr("String_Node_Str" + metaret.getExitStatus());
        if (metaret.getStdout() != null) {
          printAndAppendtoStdout("String_Node_Str" + metaret.getStdout());
        }
        if (metaret.getStderr() != null) {
          printAndAppendtoStderr("String_Node_Str" + metaret.getStderr());
        }
        System.exit(ReturnValue.SQLQUERYFAILED);
      }
    }
 else {
      metaret=meta.add_empty_processing_event(parents);
      if (metaret.getExitStatus() == ReturnValue.SUCCESS) {
        processingID=metaret.getReturnValue();
        processingAccession=meta.mapProcessingIdToAccession(processingID);
        printAndAppendtoStdout("String_Node_Str" + processingAccession);
      }
 else {
        printAndAppendtoStderr("String_Node_Str" + metaret.getExitStatus());
        if (metaret.getStdout() != null) {
          printAndAppendtoStdout("String_Node_Str" + metaret.getStdout());
        }
        if (metaret.getStderr() != null) {
          printAndAppendtoStderr("String_Node_Str" + metaret.getStderr());
        }
        System.exit(ReturnValue.SQLQUERYFAILED);
      }
    }
    if (ancestorWorkflowRunAccession > 0 && processingID > 0) {
      meta.add_workflow_run_ancestor(ancestorWorkflowRunAccession,processingID);
    }
    if (workflowRunAccession > 0 && processingID > 0) {
      meta.update_processing_workflow_run(processingID,workflowRunAccession);
    }
  }
}

Fixed version (ground truth):
private void preProcessMetadata(){
  if (optionHasOneOf(new String[]{"String_Node_Str","String_Node_Str"})) {
    Log.debug("String_Node_Str");
    return;
  }
  Map<String,String> settings=ConfigTools.getSettings();
  if (optionHasOneOf(new String[]{"String_Node_Str","String_Node_Str","String_Node_Str"})) {
    String user=options.valueOf("String_Node_Str").toString();
    String pass=options.valueOf("String_Node_Str").toString();
    String connection=options.valueOf("String_Node_Str").toString();
    try {
      meta=new MetadataDB(connection,user,pass);
    }
 catch (    SQLException e) {
      throw new RuntimeException(e);
    }
  }
 else {
    meta=MetadataFactory.get(settings);
  }
  int workflowRunId=0;
  int workflowRunAccession=0;
  ArrayList<Integer> parentIDs=new ArrayList<>();
  processingIDFiles=new ArrayList<>();
  ArrayList<Integer> parentAccessions=new ArrayList<>();
  processingAccessionFiles=new ArrayList<>();
  int ancestorWorkflowRunAccession=0;
  if (options.has("String_Node_Str")) {
    String outputFile=(String)options.valueOf("String_Node_Str");
    File file=new File(outputFile);
    try {
      if (file.exists() && file.canRead()) {
        String readFileToString=FileUtils.readFileToString(file).trim();
        try {
          int processingAccessionFromFile=Integer.valueOf(readFileToString);
          Processing proc=meta.getProcessing(processingAccessionFromFile);
          if (proc != null) {
            if (proc.getStatus().equals(ProcessingStatus.success)) {
              Log.error("String_Node_Str");
              System.exit(ReturnValue.SUCCESS);
            }
          }
        }
 catch (        NumberFormatException|NotFoundException ne) {
          Log.error("String_Node_Str");
        }
        Log.error("String_Node_Str");
      }
      if ((file.exists() || file.createNewFile()) && file.canWrite()) {
        processingAccessionFileCheck=file;
      }
 else {
        Log.error("String_Node_Str");
        System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
      }
    }
 catch (    IOException e) {
      Log.error("String_Node_Str" + e.getMessage());
      System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
    }
  }
  if (options.has("String_Node_Str")) {
    workflowRunId=meta.add_workflow_run((Integer)options.valueOf("String_Node_Str"));
    workflowRunAccession=meta.get_workflow_run_accession(workflowRunId);
    for (    String outputFile : (List<String>)options.valuesOf("String_Node_Str")) {
      File file=new File(outputFile);
      try {
        if ((file.exists() || file.createNewFile()) && file.canWrite()) {
          this.writeStringToFile(file,true,workflowRunAccession + System.getProperty("String_Node_Str"));
        }
 else {
          Log.error("String_Node_Str");
          System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
        }
      }
 catch (      IOException e) {
        Log.error("String_Node_Str" + e.getMessage());
        System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
      }
      break;
    }
  }
  List<Integer> workflowRunAccessions=(List<Integer>)options.valuesOf("String_Node_Str");
  if (workflowRunAccessions.size() == 1) {
    workflowRunAccession=workflowRunAccessions.get(0);
  }
  for (  Integer parent : (List<Integer>)options.valuesOf("String_Node_Str")) {
    parentIDs.add(parent);
  }
  for (  String file : (List<String>)options.valuesOf("String_Node_Str")) {
    try {
      BufferedReader r;
      String line;
      r=new BufferedReader(new FileReader(file));
      while ((line=r.readLine()) != null) {
        try {
          parentIDs.add(Integer.parseInt(line));
        }
 catch (        NumberFormatException ex) {
          Log.error("String_Node_Str" + line + "String_Node_Str");
          System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
        }
      }
      r.close();
    }
 catch (    Exception e) {
      Log.error("String_Node_Str" + e.getMessage());
      System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
    }
  }
  for (  Integer parent : (List<Integer>)options.valuesOf("String_Node_Str")) {
    parentAccessions.add(parent);
  }
  for (  String file : (List<String>)options.valuesOf("String_Node_Str")) {
    try {
      BufferedReader r;
      String line;
      r=new BufferedReader(new FileReader(file));
      boolean accessionFound=false;
      while ((line=r.readLine()) != null) {
        try {
          int parseInt=Integer.parseInt(line);
          parentAccessions.add(parseInt);
          int[] accessions=new int[]{parseInt};
          List<ParentAccessionModel> viaParentAccessions=meta.getViaParentAccessions(accessions);
          if (viaParentAccessions == null) {
            Log.error("String_Node_Str" + line + "String_Node_Str");
            System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
          }
          accessionFound=true;
        }
 catch (        NumberFormatException ex) {
          Log.error("String_Node_Str" + line + "String_Node_Str");
          System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
        }
      }
      r.close();
      if (!accessionFound) {
        Log.error("String_Node_Str" + file + "String_Node_Str");
        System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
      }
    }
 catch (    Exception e) {
      Log.error("String_Node_Str" + e.getMessage());
      System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
    }
  }
  for (  Integer accession : (List<Integer>)options.valuesOf("String_Node_Str")) {
    ancestorWorkflowRunAccession=accession;
  }
  for (  String file : (List<String>)options.valuesOf("String_Node_Str")) {
    try {
      BufferedReader r;
      String line;
      r=new BufferedReader(new FileReader(file));
      while ((line=r.readLine()) != null) {
        try {
          ancestorWorkflowRunAccession=Integer.parseInt(line);
        }
 catch (        NumberFormatException ex) {
          Log.error("String_Node_Str" + line + "String_Node_Str");
          System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
        }
      }
      r.close();
    }
 catch (    Exception e) {
      Log.error("String_Node_Str" + e.getMessage());
      System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
    }
  }
  for (  String outputFile : (List<String>)options.valuesOf("String_Node_Str")) {
    File file=new File(outputFile);
    try {
      if ((file.exists() || file.createNewFile()) && file.canWrite()) {
        processingIDFiles.add(file);
      }
 else {
        Log.error("String_Node_Str");
        System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
      }
    }
 catch (    IOException e) {
      Log.error("String_Node_Str" + e.getMessage());
      System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
    }
  }
  for (  String outputFile : (List<String>)options.valuesOf("String_Node_Str")) {
    File file=new File(outputFile);
    try {
      if ((file.exists() || file.createNewFile()) && file.canWrite()) {
        processingAccessionFiles.add(file);
      }
 else {
        Log.error("String_Node_Str");
        System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
      }
    }
 catch (    IOException e) {
      Log.error("String_Node_Str" + e.getMessage());
      System.exit(ReturnValue.METADATAINVALIDIDCHAIN);
    }
  }
  processingAccession=0;
  if (meta != null) {
    int[] parents=new int[parentIDs.size()];
    for (int i=0; i < parentIDs.size(); i++) {
      parents[i]=parentIDs.get(i);
    }
    int[] parentAccessionsArray=new int[parentAccessions.size()];
    for (int i=0; i < parentAccessions.size(); i++) {
      parentAccessionsArray[i]=parentAccessions.get(i);
    }
    ReturnValue metaret;
    if (parentAccessionsArray.length > 0) {
      metaret=meta.add_empty_processing_event_by_parent_accession(parentAccessionsArray);
      if (metaret.getExitStatus() == ReturnValue.SUCCESS) {
        processingID=metaret.getReturnValue();
        processingAccession=meta.mapProcessingIdToAccession(processingID);
        printAndAppendtoStdout("String_Node_Str" + processingAccession);
      }
 else {
        printAndAppendtoStderr("String_Node_Str" + metaret.getExitStatus());
        if (metaret.getStdout() != null) {
          printAndAppendtoStdout("String_Node_Str" + metaret.getStdout());
        }
        if (metaret.getStderr() != null) {
          printAndAppendtoStderr("String_Node_Str" + metaret.getStderr());
        }
        System.exit(ReturnValue.SQLQUERYFAILED);
      }
    }
 else {
      metaret=meta.add_empty_processing_event(parents);
      if (metaret.getExitStatus() == ReturnValue.SUCCESS) {
        processingID=metaret.getReturnValue();
        processingAccession=meta.mapProcessingIdToAccession(processingID);
        printAndAppendtoStdout("String_Node_Str" + processingAccession);
      }
 else {
        printAndAppendtoStderr("String_Node_Str" + metaret.getExitStatus());
        if (metaret.getStdout() != null) {
          printAndAppendtoStdout("String_Node_Str" + metaret.getStdout());
        }
        if (metaret.getStderr() != null) {
          printAndAppendtoStderr("String_Node_Str" + metaret.getStderr());
        }
        System.exit(ReturnValue.SQLQUERYFAILED);
      }
    }
    if (ancestorWorkflowRunAccession > 0 && processingID > 0) {
      meta.add_workflow_run_ancestor(ancestorWorkflowRunAccession,processingID);
    }
    if (workflowRunAccession > 0 && processingID > 0) {
      meta.update_processing_workflow_run(processingID,workflowRunAccession);
    }
  }
}