Program: 117240
Project: 117240
Buggy source:
/** 
 * readPolicy - does the work to read in policy data from a file.
 * @param policy - The path to the policy file.
 * @return - The policy data object. This *should* be either a PolicySet or a Policy.
 */
public static Object readPolicy(InputStream is){
  try {
    DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    DocumentBuilder db=dbf.newDocumentBuilder();
    Document doc=db.parse(is);
    NodeList nodes=doc.getChildNodes();
    Node node=nodes.item(0);
    Element e=null;
    if (node.getNodeType() == Node.ELEMENT_NODE) {
      e=(Element)node;
      if (e.getNamespaceURI().equals("String_Node_Str")) {
        if (e.getNodeName().endsWith("String_Node_Str")) {
          JAXBContext context=JAXBContext.newInstance(PolicyType.class);
          Unmarshaller um=context.createUnmarshaller();
          JAXBElement<PolicyType> root=um.unmarshal(e,PolicyType.class);
          return root.getValue();
        }
 else         if (e.getNodeName().endsWith("String_Node_Str")) {
          JAXBContext context=JAXBContext.newInstance(PolicySetType.class);
          Unmarshaller um=context.createUnmarshaller();
          JAXBElement<PolicySetType> root=um.unmarshal(e,PolicySetType.class);
          return root.getValue();
        }
 else {
          if (logger.isDebugEnabled()) {
            logger.debug("String_Node_Str" + e.getNodeName());
          }
        }
      }
 else {
        logger.warn("String_Node_Str" + e.getNamespaceURI());
      }
    }
 else {
      if (logger.isDebugEnabled()) {
        logger.debug("String_Node_Str" + "String_Node_Str" + node.getNodeName() + "String_Node_Str"+ node.getNodeType()+ "String_Node_Str"+ node.getNodeValue());
      }
    }
  }
 catch (  Exception e) {
    logger.error(e.getMessage());
  }
  return null;
}

Fixed version (ground truth):
/** 
 * readPolicy - does the work to read in policy data from a file.
 * @param policy - The path to the policy file.
 * @return - The policy data object. This *should* be either a PolicySet or a Policy.
 */
public static Object readPolicy(InputStream is){
  try {
    DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    DocumentBuilder db=dbf.newDocumentBuilder();
    Document doc=db.parse(is);
    NodeList nodes=doc.getChildNodes();
    Node node=null;
    for (int i=0; i < nodes.getLength(); i++) {
      if (nodes.item(i).getNodeType() != Node.COMMENT_NODE) {
        node=nodes.item(i);
        break;
      }
    }
    Element e=null;
    if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
      e=(Element)node;
      if (e.getNamespaceURI().equals("String_Node_Str")) {
        if (e.getNodeName().endsWith("String_Node_Str")) {
          JAXBContext context=JAXBContext.newInstance(PolicyType.class);
          Unmarshaller um=context.createUnmarshaller();
          JAXBElement<PolicyType> root=um.unmarshal(e,PolicyType.class);
          return root.getValue();
        }
 else         if (e.getNodeName().endsWith("String_Node_Str")) {
          JAXBContext context=JAXBContext.newInstance(PolicySetType.class);
          Unmarshaller um=context.createUnmarshaller();
          JAXBElement<PolicySetType> root=um.unmarshal(e,PolicySetType.class);
          return root.getValue();
        }
 else {
          if (logger.isDebugEnabled()) {
            logger.debug("String_Node_Str" + e.getNodeName());
          }
        }
      }
 else {
        logger.warn("String_Node_Str" + e.getNamespaceURI());
      }
    }
 else {
      if (logger.isDebugEnabled()) {
        logger.debug("String_Node_Str" + "String_Node_Str" + node.getNodeName() + "String_Node_Str"+ node.getNodeType()+ "String_Node_Str"+ node.getNodeValue());
      }
    }
  }
 catch (  Exception e) {
    logger.error(e.getMessage());
  }
  return null;
}