Program: 130015
Project: 130015
Buggy source:
/** 
 * lookup document action
 * @param loopXPath
 * @param lookupInfo
 * @param xpathOfResults
 * @param nsMapping
 * @param xpathToTypeMap
 * @param xpathToPatternMap
 * @param matchingMode
 * @return
 */
public List<Map<String,Object>> LookupDocument(String loopXPath,Map<String,Object> lookupInfo,Map<String,String> xpathOfResults,Map<String,String> nsMapping,Map<String,String> xpathToTypeMap,Map<String,String> xpathToPatternMap,String matchingMode){
  if (doc == null || lookupInfo == null) {
    return null;
  }
  List<Map<String,Object>> result=new ArrayList<Map<String,Object>>();
  org.dom4j.Document document=doc.getDocument();
  org.dom4j.XPath xpathObjectForDoc=document.createXPath(loopXPath);
  xpathObjectForDoc.setNamespaceURIs(nsMapping);
  java.util.List<org.dom4j.tree.AbstractNode> nodes=xpathObjectForDoc.selectNodes(document);
  for (  org.dom4j.tree.AbstractNode node : nodes) {
    boolean reject=false;
    for (    String xpath : lookupInfo.keySet()) {
      Object lookupValue=lookupInfo.get(xpath);
      org.dom4j.XPath xpathObjectForLookup=node.createXPath(xpath);
      xpathObjectForLookup.setNamespaceURIs(nsMapping);
      Node nodeOfLookup=xpathObjectForLookup.selectSingleNode(node);
      String text=(nodeOfLookup == null ? null : xpathObjectForLookup.valueOf(node));
      String pattern=xpathToPatternMap.get(xpath);
      String javaType=xpathToTypeMap.get(xpath);
      Object value=ParserUtils.parse(text,javaType,pattern);
      if (lookupValue == null && value == null) {
      }
 else {
        if (value == null || !value.equals(lookupValue)) {
          reject=true;
          break;
        }
      }
    }
    if (reject) {
    }
 else {
      Map<String,Object> row=new HashMap<String,Object>();
      for (      Object key : xpathOfResults.keySet()) {
        String xpath=xpathOfResults.get(key);
        org.dom4j.XPath xpathObjectForResult=node.createXPath(xpath);
        xpathObjectForResult.setNamespaceURIs(nsMapping);
        Node nodeOfResult=xpathObjectForResult.selectSingleNode(node);
        row.put(key.toString(),nodeOfResult == null ? null : nodeOfResult.getText());
      }
      result.add(row);
    }
  }
  int count=result.size();
  if (count > 0) {
    if ("String_Node_Str".equals(matchingMode)) {
      List<Map<String,Object>> singleResult=new ArrayList<Map<String,Object>>();
      singleResult.add(result.get(count - 1));
      return singleResult;
    }
 else     if ("String_Node_Str".equals(matchingMode)) {
      List<Map<String,Object>> singleResult=new ArrayList<Map<String,Object>>();
      singleResult.add(result.get(0));
      return singleResult;
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * lookup document action
 * @param loopXPath
 * @param lookupInfo
 * @param xpathOfResults
 * @param nsMapping
 * @param xpathToTypeMap
 * @param xpathToPatternMap
 * @param matchingMode
 * @return
 */
public List<Map<String,Object>> LookupDocument(String loopXPath,Map<String,Object> lookupInfo,Map<String,String> xpathOfResults,Map<String,String> nsMapping,Map<String,String> xpathToTypeMap,Map<String,String> xpathToPatternMap,String matchingMode){
  if (doc == null || lookupInfo == null) {
    return null;
  }
  List<Map<String,Object>> result=new ArrayList<Map<String,Object>>();
  org.dom4j.Document document=doc.getDocument();
  org.dom4j.XPath xpathObjectForDoc=document.createXPath(loopXPath);
  xpathObjectForDoc.setNamespaceURIs(nsMapping);
  java.util.List<org.dom4j.tree.AbstractNode> nodes=xpathObjectForDoc.selectNodes(document);
  for (  org.dom4j.tree.AbstractNode node : nodes) {
    boolean reject=false;
    if (!"String_Node_Str".equals(matchingMode)) {
      for (      String xpath : lookupInfo.keySet()) {
        Object lookupValue=lookupInfo.get(xpath);
        org.dom4j.XPath xpathObjectForLookup=node.createXPath(xpath);
        xpathObjectForLookup.setNamespaceURIs(nsMapping);
        Node nodeOfLookup=xpathObjectForLookup.selectSingleNode(node);
        String text=(nodeOfLookup == null ? null : xpathObjectForLookup.valueOf(node));
        String pattern=xpathToPatternMap.get(xpath);
        String javaType=xpathToTypeMap.get(xpath);
        Object value=ParserUtils.parse(text,javaType,pattern);
        if (lookupValue == null && value == null) {
        }
 else {
          if (value == null || !value.equals(lookupValue)) {
            reject=true;
            break;
          }
        }
      }
    }
    if (reject) {
    }
 else {
      Map<String,Object> row=new HashMap<String,Object>();
      for (      Object key : xpathOfResults.keySet()) {
        String xpath=xpathOfResults.get(key);
        org.dom4j.XPath xpathObjectForResult=node.createXPath(xpath);
        xpathObjectForResult.setNamespaceURIs(nsMapping);
        Node nodeOfResult=xpathObjectForResult.selectSingleNode(node);
        row.put(key.toString(),nodeOfResult == null ? null : nodeOfResult.getText());
      }
      result.add(row);
    }
  }
  int count=result.size();
  if (count > 0) {
    if ("String_Node_Str".equals(matchingMode)) {
      List<Map<String,Object>> singleResult=new ArrayList<Map<String,Object>>();
      singleResult.add(result.get(count - 1));
      return singleResult;
    }
 else     if ("String_Node_Str".equals(matchingMode)) {
      List<Map<String,Object>> singleResult=new ArrayList<Map<String,Object>>();
      singleResult.add(result.get(0));
      return singleResult;
    }
  }
  return result;
}