Program: 96969
Project: 96969
Buggy source:
private void parseNestedTemplateOptions(String templateOptions,IContainer folder,WordMLProducer wordMl,PresentationType presentationType){
  try {
    JSONObject jsonObject=new JSONObject(templateOptions);
    JSONArray nestedTemplateOptions=jsonObject.getJSONArray("String_Node_Str");
    JSONObject options=null;
    if (nestedCount < nestedTemplateOptions.length()) {
      options=nestedTemplateOptions.getJSONObject(nestedCount);
      nestedCount++;
      outlineType=options.getString("String_Node_Str");
      sectionNumber=options.getString("String_Node_Str");
      subDocName=options.getString("String_Node_Str");
      key=options.getString("String_Node_Str");
      value=options.getString("String_Node_Str");
      renderer.setOption(key,value);
      String artifactName=renderer.getStringOption("String_Node_Str");
      String artifactId=renderer.getStringOption("String_Node_Str");
      String orcsQuery=renderer.getStringOption("String_Node_Str");
      Branch branch=renderer.getBranchOption("String_Node_Str");
      List<Artifact> artifacts=null;
      if (Strings.isValid(artifactId)) {
        artifacts=ArtifactQuery.getArtifactListFromIds(Arrays.asList(Integer.valueOf(artifactId)),branch,EXCLUDE_DELETED);
      }
 else       if (Strings.isValid(artifactName)) {
        artifacts=ArtifactQuery.getArtifactListFromName(artifactName,branch,EXCLUDE_DELETED);
      }
 else       if (Strings.isValid(orcsQuery)) {
        Writer writer=new StringWriter();
        OseeClient oseeClient=ServiceUtil.getOseeClient();
        oseeClient.executeScript(orcsQuery,null,false,MediaType.APPLICATION_JSON_TYPE,writer);
        artifacts=parseOrcsQueryResult(writer.toString(),branch);
      }
      String subDocFileName=subDocName + "String_Node_Str";
      if (isDiff) {
        WordTemplateFileDiffer templateFileDiffer=new WordTemplateFileDiffer(renderer);
        templateFileDiffer.generateFileDifferences(artifacts,"String_Node_Str" + subDocFileName,sectionNumber,outlineType,recurseChildren);
      }
 else {
        IFile file=folder.getFile(new Path(subDocFileName));
        AIFile.writeToFile(file,applyTemplate(artifacts,slaveTemplate,slaveTemplateOptions,folder,sectionNumber,outlineType,presentationType));
      }
      wordMl.createHyperLinkDoc(subDocFileName);
    }
  }
 catch (  JSONException ex) {
    OseeCoreException.wrapAndThrow(ex);
  }
}

Fixed version (ground truth):
private void parseNestedTemplateOptions(String templateOptions,IContainer folder,WordMLProducer wordMl,PresentationType presentationType){
  try {
    JSONObject jsonObject=new JSONObject(templateOptions);
    JSONArray nestedTemplateOptions=jsonObject.getJSONArray("String_Node_Str");
    JSONObject options=null;
    if (nestedCount < nestedTemplateOptions.length()) {
      options=nestedTemplateOptions.getJSONObject(nestedCount);
      nestedCount++;
      outlineType=options.getString("String_Node_Str");
      if (outlineType.isEmpty()) {
        outlineType=null;
      }
      sectionNumber=options.getString("String_Node_Str");
      subDocName=options.getString("String_Node_Str");
      key=options.getString("String_Node_Str");
      value=options.getString("String_Node_Str");
      renderer.setOption(key,value);
      String artifactName=renderer.getStringOption("String_Node_Str");
      String artifactId=renderer.getStringOption("String_Node_Str");
      String orcsQuery=renderer.getStringOption("String_Node_Str");
      Branch branch=renderer.getBranchOption("String_Node_Str");
      List<Artifact> artifacts=null;
      if (Strings.isValid(artifactId)) {
        artifacts=ArtifactQuery.getArtifactListFromIds(Arrays.asList(Integer.valueOf(artifactId)),branch,EXCLUDE_DELETED);
      }
 else       if (Strings.isValid(artifactName)) {
        artifacts=ArtifactQuery.getArtifactListFromName(artifactName,branch,EXCLUDE_DELETED);
      }
 else       if (Strings.isValid(orcsQuery)) {
        Writer writer=new StringWriter();
        OseeClient oseeClient=ServiceUtil.getOseeClient();
        oseeClient.executeScript(orcsQuery,null,false,MediaType.APPLICATION_JSON_TYPE,writer);
        artifacts=parseOrcsQueryResult(writer.toString(),branch);
      }
      String subDocFileName=subDocName + "String_Node_Str";
      if (isDiff) {
        WordTemplateFileDiffer templateFileDiffer=new WordTemplateFileDiffer(renderer);
        templateFileDiffer.generateFileDifferences(artifacts,"String_Node_Str" + subDocFileName,sectionNumber,outlineType,recurseChildren);
      }
 else {
        IFile file=folder.getFile(new Path(subDocFileName));
        AIFile.writeToFile(file,applyTemplate(artifacts,slaveTemplate,slaveTemplateOptions,folder,sectionNumber,outlineType,presentationType));
      }
      wordMl.createHyperLinkDoc(subDocFileName);
    }
  }
 catch (  JSONException ex) {
    OseeCoreException.wrapAndThrow(ex);
  }
}