Buggy code:
public class DsXmlDeploymentInstallProcessor implements DeploymentUnitProcessor { private static final String DATA_SOURCE = "data-source" ; private static final String XA_DATA_SOURCE = "xa-data-source" ; private static final String CONNECTION_PROPERTIES = "connection-properties" ; private static final String XA_CONNECTION_PROPERTIES = "xa-datasource-properties" ; private static final PathAddress SUBSYSTEM_ADDRESS = PathAddress . pathAddress ( PathElement . pathElement ( SUBSYSTEM , SUBSYSTEM_NAME ) ) ; private static final PathAddress DATASOURCE_ADDRESS ; private static final PathAddress XA_DATASOURCE_ADDRESS ; @ Override public void deploy ( DeploymentPhaseContext phaseContext ) throws DeploymentUnitProcessingException { } private void installManagementModel ( final DataSource ds , final DeploymentUnit deploymentUnit , final PathAddress addr ) { } private void installManagementModel ( final XaDataSource ds , final DeploymentUnit deploymentUnit , final PathAddress addr ) { } private void undeployDataSource ( final DataSource ds , final DeploymentUnit deploymentUnit ) { } private void undeployXaDataSource ( final XaDataSource ds , final DeploymentUnit deploymentUnit ) { } public void undeploy ( final DeploymentUnit context ) { } private ModifiableDataSource buildDataSource ( DataSource ds ) throws ValidateException { } private ModifiableXaDataSource buildXaDataSource ( XaDataSource xads ) throws ValidateException { } private < T > T getDef ( T value , T def ) { } private void startDataSource ( final AbstractDataSourceService dataSourceService , final String jndiName , final String driverName , final ServiceTarget serviceTarget , final ServiceVerificationHandler verificationHandler , final ManagementResourceRegistration registration , final Resource resource , final String managementName ) { final ServiceName dataSourceServiceName = SERVICE_NAME_BASE . append ( jndiName ) ; final ServiceBuilder < ? > dataSourceServiceBuilder = Services . addServerExecutorDependency ( serviceTarget . addService ( dataSourceServiceName , dataSourceService ) , dataSourceService . getExecutorServiceInjector ( ) , false ) . addDependency ( TRANSACTION_INTEGRATION_SERVICE , TransactionIntegration . class , dataSourceService . getTransactionIntegrationInjector ( ) ) . addDependency ( MANAGEMENT_REPOSITORY_SERVICE , ManagementRepository . class , dataSourceService . getManagementRepositoryInjector ( ) ) . addDependency ( SERVICE_NAME , SubjectFactory . class , dataSourceService . getSubjectFactoryInjector ( ) ) . addDependency ( CCM_SERVICE , CachedConnectionManager . class , dataSourceService . getCcmInjector ( ) ) . addDependency ( JDBC_DRIVER_REGISTRY_SERVICE , DriverRegistry . class , dataSourceService . getDriverRegistryInjector ( ) ) . addDependency ( NamingService . SERVICE_NAME ) ; if ( registration . isAllowsOverride ( ) ) { ManagementResourceRegistration overrideRegistration = registration . getOverrideModel ( managementName ) ; if ( ( overrideRegistration == null ) || ( overrideRegistration . isAllowsOverride ( ) ) ) { overrideRegistration = registration . registerOverrideModel ( managementName , OVERRIDE_DS_DESC ) ; } <START_BUG> dataSourceServiceBuilder . addListener ( new org . jboss . as . connector . subsystems . datasources . DataSourceStatisticsListener ( overrideRegistration , resource , managementName ) ) ; <END_BUG> } final ServiceName driverServiceName = JBOSS . append ( "jdbc-driver" , driverName . replaceAll ( "\\." , "_" ) ) ; if ( driverServiceName != null ) { dataSourceServiceBuilder . addDependency ( driverServiceName , Driver . class , dataSourceService . getDriverInjector ( ) ) ; } final DataSourceReferenceFactoryService referenceFactoryService = new DataSourceReferenceFactoryService ( ) ; final ServiceName referenceFactoryServiceName = DataSourceReferenceFactoryService . SERVICE_NAME_BASE . append ( jndiName ) ; final ServiceBuilder < ? > referenceBuilder = serviceTarget . addService ( referenceFactoryServiceName , referenceFactoryService ) . addDependency ( dataSourceServiceName , javax . sql . DataSource . class , referenceFactoryService . getDataSourceInjector ( ) ) ; final ContextNames . BindInfo bindInfo = ContextNames . bindInfoFor ( jndiName ) ; final BinderService binderService = new BinderService ( bindInfo . getBindName ( ) ) ; final ServiceBuilder < ? > binderBuilder = serviceTarget . addService ( bindInfo . getBinderServiceName ( ) , binderService ) . addDependency ( referenceFactoryServiceName , ManagedReferenceFactory . class , binderService . getManagedObjectInjector ( ) ) . addDependency ( bindInfo . getParentContextServiceName ( ) , ServiceBasedNamingStore . class , binderService . getNamingStoreInjector ( ) ) . addListener ( new org . jboss . msc . service . AbstractServiceListener < Object > ( ) { public void transition ( final ServiceController < ? > controller , final ServiceController . Transition transition ) { switch ( transition ) { case STARTING_to_UP : { SUBSYSTEM_DATASOURCES_LOGGER . boundDataSource ( jndiName ) ; break ; } case START_REQUESTED_to_DOWN : { SUBSYSTEM_DATASOURCES_LOGGER . unboundDataSource ( jndiName ) ; break ; } case REMOVING_to_REMOVED : { SUBSYSTEM_DATASOURCES_LOGGER . debugf ( "Removed<seq2seq4repair_space>JDBC<seq2seq4repair_space>Data-source<seq2seq4repair_space>[%s]" , jndiName ) ; break ; } } } } ) ; dataSourceServiceBuilder . setInitialMode ( ACTIVE ) . addListener ( verificationHandler ) . install ( ) ; referenceBuilder . setInitialMode ( ACTIVE ) . addListener ( verificationHandler ) . install ( ) ; binderBuilder . setInitialMode ( ACTIVE ) . addListener ( verificationHandler ) . install ( ) ; } private static PathAddress getDataSourceAddress ( final String jndiName , DeploymentUnit deploymentUnit , boolean xa ) { } static ManagementResourceRegistration createDeploymentSubModel ( final PathAddress address , final DeploymentUnit unit ) { } static Resource getOrCreate ( final Resource parent , final PathAddress address ) { } private Resource getResource ( final String dsName , final boolean xa , final DeploymentUnit unit ) { } private ManagementResourceRegistration getRegistration ( final boolean xa , final DeploymentUnit unit ) { } }

Fix:
dataSourceServiceBuilder . addListener ( new org . jboss . as . connector . subsystems . datasources . DataSourceStatisticsListener ( overrideRegistration , resource , managementName , false ) ) ;