Program: 16801
Project: 16801
Buggy source:
/** 
 * Create a ValidationDefinition from a provided stream containing XML. The XML typically will look like <pre>  {@code <items> <server_host>myHost</server_host> <server_uri>https://127.0.0.1:8089</server_uri> <session_key>123102983109283019283</session_key> <checkpoint_dir>/opt/splunk/var/lib/splunk/modinputs</checkpoint_dir> <item name="myScheme"> <param name="param1">value1</param> <param_list name="param2"> <value>value2</value> <value>value3</value> <value>value4</value> </param_list> </item> </items>}</pre>
 * @param stream containing XML to parse.
 * @return a ValidationDefinition.
 * @throws ParserConfigurationException if there are errors in setting up the parser (which indicates systemconfiguration issues).
 * @throws IOException if there is an error in reading from the stream.
 * @throws SAXException when the XML is invalid.
 * @throws MalformedDataException when the XML does not meet the required schema.
 */
public static ValidationDefinition parseDefinition(InputStream stream) throws ParserConfigurationException, IOException, SAXException, MalformedDataException {
  DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newInstance();
  documentBuilderFactory.setIgnoringElementContentWhitespace(true);
  DocumentBuilder documentBuilder=documentBuilderFactory.newDocumentBuilder();
  Document doc=documentBuilder.parse(stream);
  ValidationDefinition definition=new ValidationDefinition();
  for (Node node=doc.getDocumentElement().getFirstChild(); node != null; node=node.getNextSibling()) {
    if (node.getNodeType() == node.TEXT_NODE || node.getNodeType() == node.COMMENT_NODE) {
      continue;
    }
 else     if (node.getNodeName().equals("String_Node_Str")) {
      String name=node.getAttributes().getNamedItem("String_Node_Str").getNodeValue();
      definition.setName(name);
      List<Parameter> parameter=Parameter.nodeToParameterList(node);
      definition.setParameters(parameter);
    }
 else {
      definition.metadata.put(node.getNodeName(),XmlUtil.textInNode(node,"String_Node_Str" + node.getNodeName()));
    }
  }
  return definition;
}

Fixed version (ground truth):
/** 
 * Create a ValidationDefinition from a provided stream containing XML. The XML typically will look like <pre>  {@code <items> <server_host>myHost</server_host> <server_uri>https://127.0.0.1:8089</server_uri> <session_key>123102983109283019283</session_key> <checkpoint_dir>/opt/splunk/var/lib/splunk/modinputs</checkpoint_dir> <item name="myScheme"> <param name="param1">value1</param> <param_list name="param2"> <value>value2</value> <value>value3</value> <value>value4</value> </param_list> </item> </items>}</pre>
 * @param stream containing XML to parse.
 * @return a ValidationDefinition.
 * @throws ParserConfigurationException if there are errors in setting up the parser (which indicates systemconfiguration issues).
 * @throws IOException if there is an error in reading from the stream.
 * @throws SAXException when the XML is invalid.
 * @throws MalformedDataException when the XML does not meet the required schema.
 */
public static ValidationDefinition parseDefinition(InputStream stream) throws ParserConfigurationException, IOException, SAXException, MalformedDataException {
  DocumentBuilderFactory documentBuilderFactory=DocumentBuilderFactory.newInstance();
  documentBuilderFactory.setIgnoringElementContentWhitespace(true);
  DocumentBuilder documentBuilder=documentBuilderFactory.newDocumentBuilder();
  Document doc=documentBuilder.parse(stream);
  ValidationDefinition definition=new ValidationDefinition();
  for (Node node=doc.getDocumentElement().getFirstChild(); node != null; node=node.getNextSibling()) {
    if (node.getNodeType() == Node.TEXT_NODE || node.getNodeType() == Node.COMMENT_NODE) {
      continue;
    }
 else     if (node.getNodeName().equals("String_Node_Str")) {
      String name=node.getAttributes().getNamedItem("String_Node_Str").getNodeValue();
      definition.setName(name);
      List<Parameter> parameter=Parameter.nodeToParameterList(node);
      definition.setParameters(parameter);
    }
 else {
      definition.metadata.put(node.getNodeName(),XmlUtil.textInNode(node,"String_Node_Str" + node.getNodeName()));
    }
  }
  return definition;
}