Buggy code:
public class PersistentResourceXMLDescription { protected final PersistentResourceDefinition resourceDefinition ; protected final String xmlElementName ; protected final String xmlWrapperElement ; protected final LinkedHashMap < String , AttributeDefinition > attributes ; protected final List < PersistentResourceXMLDescription > children ; protected final boolean useValueAsElementName ; protected final boolean noAddOperation ; protected final PersistentResourceXMLDescription . AdditionalOperationsGenerator additionalOperationsGenerator ; private boolean flushRequired = true ; protected PersistentResourceXMLDescription ( final PersistentResourceDefinition resourceDefinition , final String xmlElementName , final String xmlWrapperElement , final LinkedHashMap < String , AttributeDefinition > attributes , final List < PersistentResourceXMLDescription > children , final boolean useValueAsElementName , final boolean noAddOperation , final PersistentResourceXMLDescription . AdditionalOperationsGenerator additionalOperationsGenerator ) { } public void parse ( final XMLExtendedStreamReader reader , PathAddress parentAddress , List < ModelNode > list ) throws XMLStreamException { } private Map < String , PersistentResourceXMLDescription > getChildrenMap ( ) { } public void parseChildren ( final XMLExtendedStreamReader reader , PathAddress parentAddress , List < ModelNode > list ) throws XMLStreamException { } public void persist ( XMLExtendedStreamWriter writer , ModelNode model ) throws XMLStreamException { } private void writeStartElement ( XMLExtendedStreamWriter writer , String namespaceURI , String localName ) throws XMLStreamException { } public void startSubsystemElement ( XMLExtendedStreamWriter writer , String namespaceURI , boolean empty ) throws XMLStreamException { } public void persist ( XMLExtendedStreamWriter writer , ModelNode model , String namespaceURI ) throws XMLStreamException { boolean wildcard = resourceDefinition . getPathElement ( ) . isWildcard ( ) ; model = ( wildcard ) ? model . get ( resourceDefinition . getPathElement ( ) . getKey ( ) ) : model . get ( resourceDefinition . getPathElement ( ) . getKeyValuePair ( ) ) ; boolean isSubsystem = resourceDefinition . getPathElement ( ) . getKey ( ) . equals ( SUBSYSTEM ) ; if ( ( ( ! isSubsystem ) && ( ! ( model . isDefined ( ) ) ) ) && ( ! ( useValueAsElementName ) ) ) { return ; } boolean writeWrapper = ( xmlWrapperElement ) != null ; if ( writeWrapper ) { writeStartElement ( writer , namespaceURI , xmlWrapperElement ) ; } if ( wildcard ) { for ( Property p : model . asPropertyList ( ) ) { if ( useValueAsElementName ) { writeStartElement ( writer , namespaceURI , p . getName ( ) ) ; } else { writeStartElement ( writer , namespaceURI , xmlElementName ) ; writer . writeAttribute ( NAME , p . getName ( ) ) ; } for ( Map . Entry < String , AttributeDefinition > def : attributes . entrySet ( ) ) { def . getValue ( ) . getAttributeMarshaller ( ) . marshallAsAttribute ( def . getValue ( ) , p . getValue ( ) , false , writer ) ; } persistChildren ( writer , p . getValue ( ) ) ; writer . writeEndElement ( ) ; } } else { if ( useValueAsElementName ) { writeStartElement ( writer , namespaceURI , resourceDefinition . getPathElement ( ) . getValue ( ) ) ; } else if ( isSubsystem ) { startSubsystemElement ( writer , namespaceURI , children . isEmpty ( ) ) ; } else { writeStartElement ( writer , namespaceURI , xmlElementName ) ; } for ( Map . Entry < String , AttributeDefinition > def : attributes . entrySet ( ) ) { <START_BUG> def . getValue ( ) . getAttributeMarshaller ( ) . marshallAsAttribute ( def . getValue ( ) , model , true , writer ) ; <END_BUG> } persistChildren ( writer , model ) ; if ( ( ! isSubsystem ) || ( ! ( children . isEmpty ( ) ) ) ) { writer . writeEndElement ( ) ; } } if ( writeWrapper ) { writer . writeEndElement ( ) ; } } public void persistChildren ( XMLExtendedStreamWriter writer , ModelNode model ) throws XMLStreamException { } public static PersistentResourceXMLDescription . PersistentResourceXMLBuilder builder ( PersistentResourceDefinition resource ) { } public static class PersistentResourceXMLBuilder { protected final PersistentResourceDefinition resourceDefinition ; protected String xmlElementName ; protected String xmlWrapperElement ; protected boolean useValueAsElementName ; protected boolean noAddOperation ; protected PersistentResourceXMLDescription . AdditionalOperationsGenerator additionalOperationsGenerator ; protected final LinkedHashMap < String , AttributeDefinition > attributes = new LinkedHashMap < > ( ) ; protected final List < PersistentResourceXMLDescription . PersistentResourceXMLBuilder > children = new ArrayList < > ( ) ; protected PersistentResourceXMLBuilder ( final PersistentResourceDefinition resourceDefinition ) { } public PersistentResourceXMLDescription . PersistentResourceXMLBuilder addChild ( PersistentResourceXMLDescription . PersistentResourceXMLBuilder builder ) { } public PersistentResourceXMLDescription . PersistentResourceXMLBuilder addAttribute ( AttributeDefinition attribute ) { } public PersistentResourceXMLDescription . PersistentResourceXMLBuilder addAttributes ( AttributeDefinition ... attributes ) { } public PersistentResourceXMLDescription . PersistentResourceXMLBuilder addAttributes ( Collection < ? extends AttributeDefinition > attributes ) { } public PersistentResourceXMLDescription . PersistentResourceXMLBuilder setXmlWrapperElement ( final String xmlWrapperElement ) { } public PersistentResourceXMLDescription . PersistentResourceXMLBuilder setXmlElementName ( final String xmlElementName ) { } public PersistentResourceXMLDescription . PersistentResourceXMLBuilder setUseValueAsElementName ( final boolean useValueAsElementName ) { } public PersistentResourceXMLDescription . PersistentResourceXMLBuilder setNoAddOperation ( final boolean noAddOperation ) { } public PersistentResourceXMLDescription . PersistentResourceXMLBuilder setAdditionalOperationsGenerator ( final PersistentResourceXMLDescription . AdditionalOperationsGenerator additionalOperationsGenerator ) { } public PersistentResourceXMLDescription build ( ) { } } public interface AdditionalOperationsGenerator { void additionalOperations ( final PathAddress address , final ModelNode addOperation , final List < ModelNode > operations ) { } } }

Fix:
def . getValue ( ) . getAttributeMarshaller ( ) . marshallAsAttribute ( def . getValue ( ) , model , false , writer ) ;