Program: 46786
Project: 46786
Buggy source:
private String createJobSubmissionDescription(ServiceInterface serviceInterface,Document jsdl) throws ServerJobSubmissionException {
  DebugUtils.jsdlDebugOutput("String_Node_Str",jsdl);
  Document output=null;
  try {
    DocumentBuilderFactory docFactory=DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder=docFactory.newDocumentBuilder();
    output=docBuilder.newDocument();
  }
 catch (  ParserConfigurationException e1) {
    e1.printStackTrace();
  }
  Element job=output.createElement("String_Node_Str");
  output.appendChild(job);
  Element executable=output.createElement("String_Node_Str");
  executable.setTextContent(JsdlHelpers.getPosixApplication(jsdl));
  job.appendChild(executable);
  String[] arguments=JsdlHelpers.getPosixApplicationArguments(jsdl);
  for (  String argument : arguments) {
    if (argument != null && !"String_Node_Str".equals(argument.trim())) {
      Element argument_node=output.createElement("String_Node_Str");
      argument_node.setTextContent(argument);
      job.appendChild(argument_node);
    }
  }
  Element directory=output.createElement("String_Node_Str");
  directory.setTextContent(JsdlHelpers.getWorkingDirectory(jsdl));
  job.appendChild(directory);
  String stdinValue=JsdlHelpers.getPosixStandardInput(jsdl);
  if (stdinValue != null && !"String_Node_Str".equals(stdinValue)) {
    Element stdin=output.createElement("String_Node_Str");
    stdin.setTextContent(stdinValue);
    job.appendChild(stdin);
  }
  Element stdout=output.createElement("String_Node_Str");
  stdout.setTextContent(JsdlHelpers.getPosixStandardOutput(jsdl));
  job.appendChild(stdout);
  Element stderr=output.createElement("String_Node_Str");
  stderr.setTextContent(JsdlHelpers.getPosixStandardError(jsdl));
  job.appendChild(stderr);
  String queue=JsdlHelpers.getCandidateHosts(jsdl)[0];
  if (queue.indexOf("String_Node_Str") != -1) {
    queue=queue.substring(0,queue.indexOf("String_Node_Str"));
    Element queue_node=output.createElement("String_Node_Str");
    queue_node.setTextContent(queue);
    job.appendChild(queue_node);
  }
  int processorCount=JsdlHelpers.getProcessorCount(jsdl);
  Element jobType=output.createElement("String_Node_Str");
  String jobTypeString=JsdlHelpers.getJobType(jsdl);
  if (processorCount > 1) {
    Element count=output.createElement("String_Node_Str");
    count.setTextContent(new Integer(processorCount).toString());
    job.appendChild(count);
    if (jobTypeString == null) {
      jobType.setTextContent("String_Node_Str");
    }
 else {
      jobType.setTextContent(jobTypeString);
    }
  }
 else {
    if (jobTypeString == null) {
      jobType.setTextContent("String_Node_Str");
    }
 else {
      jobType.setTextContent(jobTypeString);
    }
  }
  job.appendChild(jobType);
  Long memory=JsdlHelpers.getTotalMemoryRequirement(jsdl);
  if (memory != null && memory >= 0) {
    Element totalMemory=output.createElement("String_Node_Str");
    memory=memory / 1024;
    totalMemory.setTextContent(memory.toString());
    job.appendChild(totalMemory);
  }
  int walltime=JsdlHelpers.getWalltime(jsdl);
  if (walltime > 0) {
    Element maxWallTime=output.createElement("String_Node_Str");
    int wt=new Integer(JsdlHelpers.getWalltime(jsdl));
    wt=wt / 60;
    maxWallTime.setTextContent(new Integer(wt).toString());
    job.appendChild(maxWallTime);
  }
  Element fileStageIn=output.createElement("String_Node_Str");
  Element extensions=output.createElement("String_Node_Str");
  Element jobname=output.createElement("String_Node_Str");
  String jobname_string=JsdlHelpers.getJobname(jsdl);
  if (jobname_string.length() > 6) {
    jobname.setTextContent(jobname_string.substring(jobname_string.length() - 6));
  }
  extensions.appendChild(jobname);
  String[] modules_string=null;
  try {
    modules_string=JsdlHelpers.getModules(jsdl);
  }
 catch (  Exception e) {
  }
  if (modules_string != null && modules_string.length == 0) {
    for (    String module_string : modules_string) {
      if (!"String_Node_Str".equals(module_string)) {
        Element module=output.createElement("String_Node_Str");
        module.setTextContent(module_string);
        extensions.appendChild(module);
      }
    }
  }
 else {
    String application=JsdlHelpers.getApplicationName(jsdl);
    String version=JsdlHelpers.getApplicationVersion(jsdl);
    String subLoc=JsdlHelpers.getCandidateHosts(jsdl)[0];
    if (application != null || version != null || subLoc != null) {
      Map<String,String> appDetails=serviceInterface.getApplicationDetails(application,version,subLoc);
      String modulesString=appDetails.get(JobConstants.MDS_MODULES_KEY);
      if (modules_string == null || "String_Node_Str".equals(modules_string)) {
        myLogger.warn("String_Node_Str");
      }
      if (modulesString != null && modulesString.length() > 0) {
        modules_string=appDetails.get(JobConstants.MDS_MODULES_KEY).split("String_Node_Str");
        for (        String module_string : modules_string) {
          if (!"String_Node_Str".equals(module_string)) {
            Element module=output.createElement("String_Node_Str");
            module.setTextContent(module_string);
            extensions.appendChild(module);
          }
        }
      }
    }
 else {
      throw new ServerJobSubmissionException("String_Node_Str");
    }
  }
  String email=JsdlHelpers.getEmail(jsdl);
  if (email != null && !"String_Node_Str".equals(email)) {
    Element email_address=output.createElement("String_Node_Str");
    email_address.setTextContent(email);
    extensions.appendChild(email_address);
    if (JsdlHelpers.sendEmailOnJobStart(jsdl)) {
      Element emailonexecution=output.createElement("String_Node_Str");
      emailonexecution.setTextContent("String_Node_Str");
      extensions.appendChild(emailonexecution);
    }
    if (JsdlHelpers.sendEmailOnJobFinish(jsdl)) {
      Element emailonabort=output.createElement("String_Node_Str");
      emailonabort.setTextContent("String_Node_Str");
      Element emailontermination=output.createElement("String_Node_Str");
      emailontermination.setTextContent("String_Node_Str");
      extensions.appendChild(emailonabort);
      extensions.appendChild(emailontermination);
    }
  }
  job.appendChild(extensions);
  StreamResult result=null;
  try {
    Transformer transformer=TransformerFactory.newInstance().newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT,"String_Node_Str");
    result=new StreamResult(new StringWriter());
    DOMSource source=new DOMSource(output);
    transformer.transform(source,result);
  }
 catch (  TransformerConfigurationException e) {
    e.printStackTrace();
  }
catch (  IllegalArgumentException e) {
    e.printStackTrace();
  }
catch (  TransformerFactoryConfigurationError e) {
    e.printStackTrace();
  }
catch (  TransformerException e) {
    e.printStackTrace();
  }
  return result.getWriter().toString();
}

Fixed version (ground truth):
private String createJobSubmissionDescription(ServiceInterface serviceInterface,Document jsdl) throws ServerJobSubmissionException {
  DebugUtils.jsdlDebugOutput("String_Node_Str",jsdl);
  Document output=null;
  try {
    DocumentBuilderFactory docFactory=DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder=docFactory.newDocumentBuilder();
    output=docBuilder.newDocument();
  }
 catch (  ParserConfigurationException e1) {
    e1.printStackTrace();
  }
  Element job=output.createElement("String_Node_Str");
  output.appendChild(job);
  Element executable=output.createElement("String_Node_Str");
  executable.setTextContent(JsdlHelpers.getPosixApplication(jsdl));
  job.appendChild(executable);
  String[] arguments=JsdlHelpers.getPosixApplicationArguments(jsdl);
  for (  String argument : arguments) {
    if (argument != null && !"String_Node_Str".equals(argument.trim())) {
      Element argument_node=output.createElement("String_Node_Str");
      argument_node.setTextContent(argument);
      job.appendChild(argument_node);
    }
  }
  Element directory=output.createElement("String_Node_Str");
  directory.setTextContent(JsdlHelpers.getWorkingDirectory(jsdl));
  job.appendChild(directory);
  String stdinValue=JsdlHelpers.getPosixStandardInput(jsdl);
  if (stdinValue != null && !"String_Node_Str".equals(stdinValue)) {
    Element stdin=output.createElement("String_Node_Str");
    stdin.setTextContent(stdinValue);
    job.appendChild(stdin);
  }
  Element stdout=output.createElement("String_Node_Str");
  stdout.setTextContent(JsdlHelpers.getPosixStandardOutput(jsdl));
  job.appendChild(stdout);
  Element stderr=output.createElement("String_Node_Str");
  stderr.setTextContent(JsdlHelpers.getPosixStandardError(jsdl));
  job.appendChild(stderr);
  String queue=JsdlHelpers.getCandidateHosts(jsdl)[0];
  if (queue.indexOf("String_Node_Str") != -1) {
    queue=queue.substring(0,queue.indexOf("String_Node_Str"));
    Element queue_node=output.createElement("String_Node_Str");
    queue_node.setTextContent(queue);
    job.appendChild(queue_node);
  }
  int processorCount=JsdlHelpers.getProcessorCount(jsdl);
  Element jobType=output.createElement("String_Node_Str");
  String jobTypeString=JsdlHelpers.getJobType(jsdl);
  if (processorCount > 1) {
    Element count=output.createElement("String_Node_Str");
    count.setTextContent(new Integer(processorCount).toString());
    job.appendChild(count);
    if (jobTypeString == null) {
      jobType.setTextContent("String_Node_Str");
    }
 else {
      jobType.setTextContent(jobTypeString);
    }
  }
 else {
    if (jobTypeString == null) {
      jobType.setTextContent("String_Node_Str");
    }
 else {
      jobType.setTextContent(jobTypeString);
    }
  }
  job.appendChild(jobType);
  Long memory=JsdlHelpers.getTotalMemoryRequirement(jsdl);
  if (memory != null && memory >= 0) {
    Element totalMemory=output.createElement("String_Node_Str");
    memory=memory / 1024;
    totalMemory.setTextContent(memory.toString());
    job.appendChild(totalMemory);
  }
  int walltime=JsdlHelpers.getWalltime(jsdl);
  if (walltime > 0) {
    Element maxWallTime=output.createElement("String_Node_Str");
    int wt=new Integer(JsdlHelpers.getWalltime(jsdl));
    wt=wt / 60;
    maxWallTime.setTextContent(new Integer(wt).toString());
    job.appendChild(maxWallTime);
  }
  Element fileStageIn=output.createElement("String_Node_Str");
  Element extensions=output.createElement("String_Node_Str");
  Element jobname=output.createElement("String_Node_Str");
  String jobname_string=JsdlHelpers.getJobname(jsdl);
  if (jobname_string.length() > 6) {
    jobname.setTextContent(jobname_string.substring(jobname_string.length() - 6));
  }
  extensions.appendChild(jobname);
  String[] modules_string=null;
  try {
    modules_string=JsdlHelpers.getModules(jsdl);
  }
 catch (  Exception e) {
  }
  if (modules_string != null && modules_string.length > 0) {
    for (    String module_string : modules_string) {
      if (!"String_Node_Str".equals(module_string)) {
        Element module=output.createElement("String_Node_Str");
        module.setTextContent(module_string);
        extensions.appendChild(module);
      }
    }
  }
 else {
    String application=JsdlHelpers.getApplicationName(jsdl);
    String version=JsdlHelpers.getApplicationVersion(jsdl);
    String subLoc=JsdlHelpers.getCandidateHosts(jsdl)[0];
    if (application != null || version != null || subLoc != null) {
      Map<String,String> appDetails=serviceInterface.getApplicationDetails(application,version,subLoc);
      String modulesString=appDetails.get(JobConstants.MDS_MODULES_KEY);
      if (modules_string == null || "String_Node_Str".equals(modules_string)) {
        myLogger.warn("String_Node_Str");
      }
      if (modulesString != null && modulesString.length() > 0) {
        modules_string=appDetails.get(JobConstants.MDS_MODULES_KEY).split("String_Node_Str");
        for (        String module_string : modules_string) {
          if (!"String_Node_Str".equals(module_string)) {
            Element module=output.createElement("String_Node_Str");
            module.setTextContent(module_string);
            extensions.appendChild(module);
          }
        }
      }
    }
 else {
      throw new ServerJobSubmissionException("String_Node_Str");
    }
  }
  String email=JsdlHelpers.getEmail(jsdl);
  if (email != null && !"String_Node_Str".equals(email)) {
    Element email_address=output.createElement("String_Node_Str");
    email_address.setTextContent(email);
    extensions.appendChild(email_address);
    if (JsdlHelpers.sendEmailOnJobStart(jsdl)) {
      Element emailonexecution=output.createElement("String_Node_Str");
      emailonexecution.setTextContent("String_Node_Str");
      extensions.appendChild(emailonexecution);
    }
    if (JsdlHelpers.sendEmailOnJobFinish(jsdl)) {
      Element emailonabort=output.createElement("String_Node_Str");
      emailonabort.setTextContent("String_Node_Str");
      Element emailontermination=output.createElement("String_Node_Str");
      emailontermination.setTextContent("String_Node_Str");
      extensions.appendChild(emailonabort);
      extensions.appendChild(emailontermination);
    }
  }
  job.appendChild(extensions);
  StreamResult result=null;
  try {
    Transformer transformer=TransformerFactory.newInstance().newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT,"String_Node_Str");
    result=new StreamResult(new StringWriter());
    DOMSource source=new DOMSource(output);
    transformer.transform(source,result);
  }
 catch (  TransformerConfigurationException e) {
    e.printStackTrace();
  }
catch (  IllegalArgumentException e) {
    e.printStackTrace();
  }
catch (  TransformerFactoryConfigurationError e) {
    e.printStackTrace();
  }
catch (  TransformerException e) {
    e.printStackTrace();
  }
  return result.getWriter().toString();
}