Buggy code:
public class PersistenceUnitXmlParser extends MetaDataElementParser { private static final boolean traceEnabled = JpaLogger . JPA_LOGGER . isTraceEnabled ( ) ; public static PersistenceUnitMetadataHolder parse ( final XMLStreamReader reader ) throws XMLStreamException { reader . require ( START_DOCUMENT , null , null ) ; Version version = null ; while ( ( reader . hasNext ( ) ) && ( ( reader . next ( ) ) != ( START_ELEMENT ) ) ) { if ( ( reader . getEventType ( ) ) == ( DTD ) ) { final String dtdLocation = readDTDLocation ( reader ) ; if ( dtdLocation != null ) { version = Version . forLocation ( dtdLocation ) ; } } } final String schemaLocation = readSchemaLocation ( reader ) ; if ( schemaLocation != null ) { version = Version . forLocation ( schemaLocation ) ; } if ( ( version == null ) || ( UNKNOWN . equals ( version ) ) ) { String versionString = null ; final int count = reader . getAttributeCount ( ) ; for ( int i = 0 ; i < count ; i ++ ) { final String attributeNamespace = reader . getAttributeNamespace ( i ) ; if ( ( attributeNamespace != null ) && ( ! ( attributeNamespace . isEmpty ( ) ) ) ) { continue ; } final Attribute attribute = Attribute . forName ( reader . getAttributeLocalName ( i ) ) ; if ( attribute == ( Attribute . VERSION ) ) { versionString = reader . getAttributeValue ( i ) ; } } if ( "1.0" . equals ( versionString ) ) { version = Version . JPA_1_0 ; } else if ( "1" . equals ( versionString ) ) { version = Version . JPA_1_0 ; } else if ( "2.0" . equals ( versionString ) ) { version = Version . JPA_2_0 ; } else if ( "2" . equals ( versionString ) ) { version = Version . JPA_2_0 ; } else { version = Version . JPA_2_0 ; } } final int count = reader . getAttributeCount ( ) ; for ( int i = 0 ; i < count ; i ++ ) { final String value = reader . getAttributeValue ( i ) ; final String attributeNamespace = reader . getAttributeNamespace ( i ) ; if ( ( attributeNamespace != null ) && ( ! ( attributeNamespace . isEmpty ( ) ) ) ) { continue ; } final Attribute attribute = Attribute . forName ( reader . getAttributeLocalName ( i ) ) ; switch ( attribute ) { case VERSION : break ; default : throw unexpectedAttribute ( reader , i ) ; } } final List < PersistenceUnitMetadata > PUs = new ArrayList < PersistenceUnitMetadata > ( ) ; while ( ( reader . hasNext ( ) ) && ( ( reader . nextTag ( ) ) != ( END_ELEMENT ) ) ) { final Element element = Element . forName ( reader . getLocalName ( ) ) ; switch ( element ) { case PERSISTENCEUNIT : PersistenceUnitMetadata pu = PersistenceUnitXmlParser . parsePU ( reader , version ) ; PUs . add ( pu ) ; JpaLogger . JPA_LOGGER . readingPersistenceXml ( pu . getPersistenceUnitName ( ) ) ; break ; default : throw unexpectedElement ( reader ) ; } } <START_BUG> PersistenceUnitMetadataHolder result = new PersistenceUnitMetadataHolder ( ) . setPersistenceUnits ( PUs ) ; <END_BUG> if ( JpaLogger . JPA_LOGGER . isTraceEnabled ( ) ) JpaLogger . JPA_LOGGER . trace ( result . toString ( ) ) ; return result ; } private static PersistenceUnitMetadata parsePU ( XMLStreamReader reader , Version version ) throws XMLStreamException { } private static void parseProperties ( XMLStreamReader reader , Properties properties ) throws XMLStreamException { } public static void main ( String [ ] args ) { } }

Fix:
PersistenceUnitMetadataHolder result = new PersistenceUnitMetadataHolder ( PUs ) ;