Program: 100806
Project: 100806
Buggy source:
private void handleTopicref(final Node topicref,final Hashtable<String,Element> inheritance){
  final Node hrefAttr=topicref.getAttributes().getNamedItem(ATTRIBUTE_NAME_HREF);
  final Node copytoAttr=topicref.getAttributes().getNamedItem(ATTRIBUTE_NAME_COPY_TO);
  final Node scopeAttr=topicref.getAttributes().getNamedItem(ATTRIBUTE_NAME_SCOPE);
  final Node formatAttr=topicref.getAttributes().getNamedItem(ATTRIBUTE_NAME_FORMAT);
  Hashtable<String,Element> current=mergeMeta(null,inheritance,cascadeSet);
  String topicPath=null;
  Node metaNode=null;
  final NodeList children=topicref.getChildNodes();
  for (int i=0; i < children.getLength(); i++) {
    final Node node=children.item(i);
    Node classAttr=null;
    if (node.getNodeType() == Node.ELEMENT_NODE) {
      classAttr=node.getAttributes().getNamedItem(ATTRIBUTE_NAME_CLASS);
    }
    if (classAttr != null && hrefAttr != null && MAP_TOPICMETA.matches(classAttr.getNodeValue()) && hrefAttr != null && hrefAttr.getNodeValue().indexOf(INTERNET_LINK_MARK) == -1 && (scopeAttr == null || ATTR_SCOPE_VALUE_LOCAL.equalsIgnoreCase(scopeAttr.getNodeValue())) && ((formatAttr == null || ATTR_FORMAT_VALUE_DITA.equalsIgnoreCase(formatAttr.getNodeValue())) || (formatAttr == null || ATTR_FORMAT_VALUE_DITAMAP.equalsIgnoreCase(formatAttr.getNodeValue())))) {
      metaNode=node;
      current=handleMeta(node,inheritance);
    }
 else     if (classAttr != null && MAP_TOPICREF.matches(classAttr.getNodeValue())) {
      handleTopicref(node,current);
    }
  }
  if (!current.isEmpty() && hrefAttr != null) {
    if (copytoAttr != null && new File(FileUtils.resolveFile(filePath,copytoAttr.getNodeValue())).exists()) {
      topicPath=FileUtils.resolveTopic(filePath,copytoAttr.getNodeValue());
    }
 else {
      topicPath=FileUtils.resolveTopic(filePath,hrefAttr.getNodeValue());
    }
    if (((formatAttr == null || ATTR_FORMAT_VALUE_DITA.equalsIgnoreCase(formatAttr.getNodeValue())) || (formatAttr == null || ATTR_FORMAT_VALUE_DITAMAP.equalsIgnoreCase(formatAttr.getNodeValue()))) && (scopeAttr == null || ATTR_SCOPE_VALUE_LOCAL.equalsIgnoreCase(scopeAttr.getNodeValue())) && (hrefAttr.getNodeValue().indexOf(INTERNET_LINK_MARK) == -1)) {
      if (resultTable.containsKey(topicPath)) {
        final Hashtable<String,Element> previous=resultTable.get(topicPath);
        resultTable.put(topicPath,mergeMeta(previous,current,metaSet));
      }
 else {
        resultTable.put(topicPath,cloneElementMap(current));
      }
      final Hashtable<String,Element> metas=resultTable.get(topicPath);
      if (!metas.isEmpty()) {
        if (metaNode != null) {
          topicref.removeChild(metaNode);
        }
        final Element newMeta=doc.createElement(MAP_TOPICMETA.localName);
        newMeta.setAttribute(ATTRIBUTE_NAME_CLASS,"String_Node_Str" + MAP_TOPICMETA.matcher);
        for (int i=0; i < metaPos.size(); i++) {
          final Node stub=metas.get(metaPos.get(i));
          if (stub != null) {
            final NodeList clist=stub.getChildNodes();
            for (int j=0; j < clist.getLength(); j++) {
              newMeta.appendChild(topicref.getOwnerDocument().importNode(clist.item(j),true));
            }
          }
        }
        topicref.insertBefore(newMeta,topicref.getFirstChild());
      }
    }
  }
}

Fixed version (ground truth):
private void handleTopicref(final Node topicref,final Hashtable<String,Element> inheritance){
  final Node hrefAttr=topicref.getAttributes().getNamedItem(ATTRIBUTE_NAME_HREF);
  final Node copytoAttr=topicref.getAttributes().getNamedItem(ATTRIBUTE_NAME_COPY_TO);
  final Node scopeAttr=topicref.getAttributes().getNamedItem(ATTRIBUTE_NAME_SCOPE);
  final Node formatAttr=topicref.getAttributes().getNamedItem(ATTRIBUTE_NAME_FORMAT);
  Hashtable<String,Element> current=mergeMeta(null,inheritance,cascadeSet);
  String topicPath=null;
  Node metaNode=null;
  final NodeList children=topicref.getChildNodes();
  for (int i=0; i < children.getLength(); i++) {
    final Node node=children.item(i);
    Node classAttr=null;
    if (node.getNodeType() == Node.ELEMENT_NODE) {
      classAttr=node.getAttributes().getNamedItem(ATTRIBUTE_NAME_CLASS);
    }
    if (classAttr != null && hrefAttr != null && MAP_TOPICMETA.matches(classAttr.getNodeValue()) && hrefAttr != null && hrefAttr.getNodeValue().indexOf(INTERNET_LINK_MARK) == -1 && (scopeAttr == null || ATTR_SCOPE_VALUE_LOCAL.equalsIgnoreCase(scopeAttr.getNodeValue())) && ((formatAttr == null || ATTR_FORMAT_VALUE_DITA.equalsIgnoreCase(formatAttr.getNodeValue())) || (formatAttr == null || ATTR_FORMAT_VALUE_DITAMAP.equalsIgnoreCase(formatAttr.getNodeValue())))) {
      metaNode=node;
      current=handleMeta(node,inheritance);
    }
 else     if (classAttr != null && MAP_TOPICREF.matches(classAttr.getNodeValue())) {
      handleTopicref(node,current);
    }
  }
  if (!current.isEmpty() && hrefAttr != null) {
    if (copytoAttr != null && new File(FileUtils.resolveFile(filePath,URLUtils.decode(copytoAttr.getNodeValue()))).exists()) {
      topicPath=FileUtils.resolveTopic(filePath,URLUtils.decode(copytoAttr.getNodeValue()));
    }
 else {
      topicPath=FileUtils.resolveTopic(filePath,URLUtils.decode(hrefAttr.getNodeValue()));
    }
    if (((formatAttr == null || ATTR_FORMAT_VALUE_DITA.equalsIgnoreCase(formatAttr.getNodeValue())) || (formatAttr == null || ATTR_FORMAT_VALUE_DITAMAP.equalsIgnoreCase(formatAttr.getNodeValue()))) && (scopeAttr == null || ATTR_SCOPE_VALUE_LOCAL.equalsIgnoreCase(scopeAttr.getNodeValue())) && (hrefAttr.getNodeValue().indexOf(INTERNET_LINK_MARK) == -1)) {
      if (resultTable.containsKey(topicPath)) {
        final Hashtable<String,Element> previous=resultTable.get(topicPath);
        resultTable.put(topicPath,mergeMeta(previous,current,metaSet));
      }
 else {
        resultTable.put(topicPath,cloneElementMap(current));
      }
      final Hashtable<String,Element> metas=resultTable.get(topicPath);
      if (!metas.isEmpty()) {
        if (metaNode != null) {
          topicref.removeChild(metaNode);
        }
        final Element newMeta=doc.createElement(MAP_TOPICMETA.localName);
        newMeta.setAttribute(ATTRIBUTE_NAME_CLASS,"String_Node_Str" + MAP_TOPICMETA.matcher);
        for (int i=0; i < metaPos.size(); i++) {
          final Node stub=metas.get(metaPos.get(i));
          if (stub != null) {
            final NodeList clist=stub.getChildNodes();
            for (int j=0; j < clist.getLength(); j++) {
              newMeta.appendChild(topicref.getOwnerDocument().importNode(clist.item(j),true));
            }
          }
        }
        topicref.insertBefore(newMeta,topicref.getFirstChild());
      }
    }
  }
}