Program: 167436
Project: 167436
Buggy source:
@Override public void handle(Message inputMessage,ISendMessageCallback callback,boolean unitOfWorkBoundaryReached){
  ArrayList<EntityData> inputRows=inputMessage.getPayload();
  ArrayList<String> outputPayload=new ArrayList<String>();
  Document document=templateDocument.clone();
  Map<Element,Namespace> namespaces=removeNamespaces(document);
  for (  XmlFormatterEntitySetting entitySetting : entitySettings.values()) {
    List<Element> matches=entitySetting.getExpression().evaluate(document.getRootElement());
    for (    Element element : matches) {
      entitySetting.setParentElement(element.getParentElement());
    }
  }
  for (  EntityData inputRow : inputRows) {
    processInputRow(document,inputRow);
  }
  restoreNamespaces(document,namespaces);
  XMLOutputter xmlOutputter=new XMLOutputter();
  Format format=null;
  if (xmlFormat.equals(COMPACT_FORMAT)) {
    format=Format.getCompactFormat();
  }
 else   if (xmlFormat.equals(RAW_FORMAT)) {
    format=Format.getRawFormat();
  }
 else {
    format=Format.getPrettyFormat();
  }
  xmlOutputter.setFormat(format);
  outputPayload.add(xmlOutputter.outputString(document));
  log(LogLevel.DEBUG,outputPayload.toString());
  callback.sendMessage(outputPayload,unitOfWorkBoundaryReached);
}

Fixed version (ground truth):
@Override public void handle(Message inputMessage,ISendMessageCallback callback,boolean unitOfWorkBoundaryReached){
  ArrayList<EntityData> inputRows=inputMessage.getPayload();
  ArrayList<String> outputPayload=new ArrayList<String>();
  SAXBuilder builder=new SAXBuilder();
  builder.setXMLReaderFactory(XMLReaders.NONVALIDATING);
  builder.setFeature("String_Node_Str",false);
  Document document=null;
  try {
    document=builder.build(new StringReader(FormatUtils.replaceTokens(template,context.getFlowParametersAsString(),true)));
  }
 catch (  RuntimeException e) {
    throw e;
  }
catch (  Exception e) {
    throw new RuntimeException(e);
  }
  Model model=getComponent().getInputModel();
  Map<String,XmlFormatterEntitySetting> entitySettings=new HashMap<String,XmlFormatterEntitySetting>();
  List<XmlFormatterAttributeSetting> attributeSettings=new ArrayList<XmlFormatterAttributeSetting>();
  if (model != null) {
    Map<Element,Namespace> namespaces=removeNamespaces(document);
    for (    ComponentEntitySetting compEntitySetting : getComponent().getEntitySettings()) {
      if (compEntitySetting.getName().equals(XML_FORMATTER_XPATH)) {
        XPathExpression<Element> expression=XPathFactory.instance().compile(compEntitySetting.getValue(),Filters.element());
        List<Element> matches=expression.evaluate(document.getRootElement());
        if (matches.size() == 0) {
          log(LogLevel.WARN,"String_Node_Str" + compEntitySetting.getValue() + "String_Node_Str");
        }
 else {
          Element templateElement=matches.get(0);
          entitySettings.put(compEntitySetting.getEntityId(),new XmlFormatterEntitySetting(compEntitySetting,expression,templateElement));
        }
      }
    }
    restoreNamespaces(document,namespaces);
    for (    ComponentAttributeSetting compAttrSetting : getComponent().getAttributeSettings()) {
      if (compAttrSetting.getName().equals(XML_FORMATTER_XPATH)) {
        ModelAttribute attr=model.getAttributeById(compAttrSetting.getAttributeId());
        if (attr != null) {
          XPathExpression<Object> expression=XPathFactory.instance().compile(compAttrSetting.getValue());
          XmlFormatterEntitySetting entitySetting=entitySettings.get(attr.getEntityId());
          XmlFormatterAttributeSetting attrSetting=new XmlFormatterAttributeSetting(compAttrSetting,expression);
          if (entitySetting != null) {
            entitySetting.getAttributeSettings().add(attrSetting);
          }
 else {
            attributeSettings.add(attrSetting);
          }
        }
      }
    }
  }
  Map<Element,Namespace> namespaces=removeNamespaces(document);
  for (  XmlFormatterEntitySetting entitySetting : entitySettings.values()) {
    List<Element> matches=entitySetting.getExpression().evaluate(document.getRootElement());
    for (    Element element : matches) {
      entitySetting.setParentElement(element.getParentElement());
    }
  }
  for (  EntityData inputRow : inputRows) {
    processInputRow(document,inputRow,entitySettings,attributeSettings);
  }
  restoreNamespaces(document,namespaces);
  XMLOutputter xmlOutputter=new XMLOutputter();
  Format format=null;
  if (xmlFormat.equals(COMPACT_FORMAT)) {
    format=Format.getCompactFormat();
  }
 else   if (xmlFormat.equals(RAW_FORMAT)) {
    format=Format.getRawFormat();
  }
 else {
    format=Format.getPrettyFormat();
  }
  xmlOutputter.setFormat(format);
  outputPayload.add(xmlOutputter.outputString(document));
  log(LogLevel.DEBUG,outputPayload.toString());
  callback.sendMessage(outputPayload,unitOfWorkBoundaryReached);
}