Program: 167963
Project: 167963
Buggy source:
@Override public void writeContent(final XMLExtendedStreamWriter writer,final ModelMarshallingContext context) throws XMLStreamException {
  ModelNode modelNode=context.getModelNode();
  writer.writeStartDocument();
  writer.writeStartElement(Element.DOMAIN.getLocalName());
  writer.writeDefaultNamespace(Namespace.CURRENT.getUriString());
  writeNamespaces(writer,modelNode);
  writeSchemaLocation(writer,modelNode);
  if (modelNode.hasDefined(EXTENSION)) {
    writeExtensions(writer,modelNode.get(EXTENSION));
  }
  if (modelNode.hasDefined(PATH)) {
    writePaths(writer,modelNode.get(PATH));
  }
  if (modelNode.hasDefined(PROFILE)) {
    writer.writeStartElement(Element.PROFILES.getLocalName());
    for (    final Property profile : modelNode.get(PROFILE).asPropertyList()) {
      writeProfile(writer,profile.getName(),profile.getValue(),context);
    }
    writer.writeEndElement();
  }
  if (modelNode.hasDefined(INTERFACE)) {
    writeInterfaces(writer,modelNode.get(INTERFACE));
  }
  if (modelNode.hasDefined(SOCKET_BINDING_GROUP)) {
    writer.writeStartElement(Element.SOCKET_BINDING_GROUPS.getLocalName());
    for (    final Property property : modelNode.get(SOCKET_BINDING_GROUP).asPropertyList()) {
      writeSocketBindingGroup(writer,property.getValue(),false);
    }
    writer.writeEndElement();
  }
  if (modelNode.hasDefined(SYSTEM_PROPERTIES)) {
    writeProperties(writer,modelNode,Element.SYSTEM_PROPERTIES);
  }
  if (modelNode.hasDefined(DEPLOYMENT)) {
    writeDomainDeployments(writer,modelNode);
  }
  if (modelNode.hasDefined(SERVER_GROUP)) {
    writer.writeStartElement(Element.SERVER_GROUPS.getLocalName());
    for (    final Property property : modelNode.get(SERVER_GROUP).asPropertyList()) {
      writeServerGroup(writer,property.getName(),property.getValue());
    }
    writer.writeEndElement();
  }
  writer.writeEndElement();
  writer.writeEndDocument();
}

Fixed version (ground truth):
@Override public void writeContent(final XMLExtendedStreamWriter writer,final ModelMarshallingContext context) throws XMLStreamException {
  ModelNode modelNode=context.getModelNode();
  writer.writeStartDocument();
  writer.writeStartElement(Element.DOMAIN.getLocalName());
  writer.writeDefaultNamespace(Namespace.CURRENT.getUriString());
  writeNamespaces(writer,modelNode);
  writeSchemaLocation(writer,modelNode);
  if (modelNode.hasDefined(EXTENSION)) {
    writeExtensions(writer,modelNode.get(EXTENSION));
  }
  if (modelNode.hasDefined(PATH)) {
    writePaths(writer,modelNode.get(PATH));
  }
  if (modelNode.hasDefined(PROFILE)) {
    writer.writeStartElement(Element.PROFILES.getLocalName());
    for (    final Property profile : modelNode.get(PROFILE).asPropertyList()) {
      writeProfile(writer,profile.getName(),profile.getValue(),context);
    }
    writer.writeEndElement();
  }
  if (modelNode.hasDefined(INTERFACE)) {
    writeInterfaces(writer,modelNode.get(INTERFACE));
  }
  if (modelNode.hasDefined(SOCKET_BINDING_GROUP)) {
    writer.writeStartElement(Element.SOCKET_BINDING_GROUPS.getLocalName());
    for (    final Property property : modelNode.get(SOCKET_BINDING_GROUP).asPropertyList()) {
      writeSocketBindingGroup(writer,property.getValue(),false);
    }
    writer.writeEndElement();
  }
  if (modelNode.hasDefined(SYSTEM_PROPERTIES)) {
    writeProperties(writer,modelNode.get(SYSTEM_PROPERTIES),Element.SYSTEM_PROPERTIES);
  }
  if (modelNode.hasDefined(DEPLOYMENT)) {
    writeDomainDeployments(writer,modelNode.get(DEPLOYMENT));
  }
  if (modelNode.hasDefined(SERVER_GROUP)) {
    writer.writeStartElement(Element.SERVER_GROUPS.getLocalName());
    for (    final Property property : modelNode.get(SERVER_GROUP).asPropertyList()) {
      writeServerGroup(writer,property.getName(),property.getValue());
    }
    writer.writeEndElement();
  }
  writer.writeEndElement();
  writer.writeEndDocument();
}