Program: 167937
Project: 167937
Buggy source:
protected void writeSocketBindingGroup(XMLExtendedStreamWriter writer,ModelNode bindingGroup,boolean fromServer) throws XMLStreamException {
  writer.writeStartElement(Element.SOCKET_BINDING_GROUP.getLocalName());
  ModelNode attr=bindingGroup.get(NAME);
  writeAttribute(writer,Attribute.NAME,attr.asString());
  attr=bindingGroup.get(DEFAULT_INTERFACE);
  writeAttribute(writer,Attribute.DEFAULT_INTERFACE,attr.asString());
  if (fromServer && bindingGroup.has(PORT_OFFSET) && bindingGroup.get(PORT_OFFSET).asInt() != 0) {
    attr=bindingGroup.get(PORT_OFFSET);
    writeAttribute(writer,Attribute.PORT_OFFSET,attr.asString());
  }
  if (!fromServer && bindingGroup.hasDefined(INCLUDES)) {
    for (    ModelNode include : bindingGroup.get(INCLUDES).asList()) {
      writer.writeStartElement(Element.INCLUDE.getLocalName());
      writeAttribute(writer,Attribute.SOCKET_BINDING_GROUP,include.asString());
      writer.writeEndElement();
    }
  }
  if (bindingGroup.hasDefined(SOCKET_BINDING)) {
    ModelNode bindings=bindingGroup.get(SOCKET_BINDING);
    for (    String bindingName : bindings.keys()) {
      ModelNode binding=bindings.get(bindingName);
      writer.writeStartElement(Element.SOCKET_BINDING.getLocalName());
      writeAttribute(writer,Attribute.NAME,bindingName);
      attr=binding.get(PORT);
      writeAttribute(writer,Attribute.PORT,attr.asString());
      attr=binding.get(FIXED_PORT);
      if (attr.isDefined() && attr.asBoolean()) {
        writeAttribute(writer,Attribute.FIXED_PORT,attr.asString());
      }
      attr=binding.get(INTERFACE);
      if (attr.isDefined()) {
        writeAttribute(writer,Attribute.INTERFACE,attr.asString());
      }
      attr=binding.get(MULTICAST_ADDRESS);
      if (attr.isDefined()) {
        writeAttribute(writer,Attribute.MULTICAST_ADDRESS,attr.asString());
      }
      attr=binding.get(MULTICAST_PORT);
      if (attr.isDefined()) {
        writeAttribute(writer,Attribute.MULTICAST_PORT,attr.asString());
      }
      writer.writeEndElement();
    }
  }
  writer.writeEndElement();
}

Fixed version (ground truth):
protected void writeSocketBindingGroup(XMLExtendedStreamWriter writer,ModelNode bindingGroup,boolean fromServer) throws XMLStreamException {
  writer.writeStartElement(Element.SOCKET_BINDING_GROUP.getLocalName());
  ModelNode attr=bindingGroup.get(NAME);
  writeAttribute(writer,Attribute.NAME,attr.asString());
  attr=bindingGroup.get(DEFAULT_INTERFACE);
  writeAttribute(writer,Attribute.DEFAULT_INTERFACE,attr.asString());
  if (fromServer && bindingGroup.hasDefined(PORT_OFFSET) && bindingGroup.get(PORT_OFFSET).asInt() >= 0) {
    attr=bindingGroup.get(PORT_OFFSET);
    writeAttribute(writer,Attribute.PORT_OFFSET,attr.asString());
  }
  if (!fromServer && bindingGroup.hasDefined(INCLUDES)) {
    for (    ModelNode include : bindingGroup.get(INCLUDES).asList()) {
      writer.writeStartElement(Element.INCLUDE.getLocalName());
      writeAttribute(writer,Attribute.SOCKET_BINDING_GROUP,include.asString());
      writer.writeEndElement();
    }
  }
  if (bindingGroup.hasDefined(SOCKET_BINDING)) {
    ModelNode bindings=bindingGroup.get(SOCKET_BINDING);
    for (    String bindingName : bindings.keys()) {
      ModelNode binding=bindings.get(bindingName);
      writer.writeStartElement(Element.SOCKET_BINDING.getLocalName());
      writeAttribute(writer,Attribute.NAME,bindingName);
      attr=binding.get(PORT);
      writeAttribute(writer,Attribute.PORT,attr.asString());
      attr=binding.get(FIXED_PORT);
      if (attr.isDefined() && attr.asBoolean()) {
        writeAttribute(writer,Attribute.FIXED_PORT,attr.asString());
      }
      attr=binding.get(INTERFACE);
      if (attr.isDefined()) {
        writeAttribute(writer,Attribute.INTERFACE,attr.asString());
      }
      attr=binding.get(MULTICAST_ADDRESS);
      if (attr.isDefined()) {
        writeAttribute(writer,Attribute.MULTICAST_ADDRESS,attr.asString());
      }
      attr=binding.get(MULTICAST_PORT);
      if (attr.isDefined()) {
        writeAttribute(writer,Attribute.MULTICAST_PORT,attr.asString());
      }
      writer.writeEndElement();
    }
  }
  writer.writeEndElement();
}