Buggy code:
public class ApplyRemoteMasterDomainModelHandler implements OperationStepHandler , DescriptionProvider { public static final String OPERATION_NAME = "apply-remote-domain-model" ; private final Set < String > appliedExtensions = new HashSet < String > ( ) ; private final HostFileRepository fileRepository ; private final ContentRepository contentRepository ; private final ExtensionRegistry extensionRegistry ; private final IgnoredDomainResourceRegistry ignoredResourceRegistry ; private final LocalHostControllerInfo localHostInfo ; public ApplyRemoteMasterDomainModelHandler ( final ExtensionRegistry extensionRegistry , final HostFileRepository fileRepository , final ContentRepository contentRepository , final LocalHostControllerInfo localHostInfo , final IgnoredDomainResourceRegistry ignoredResourceRegistry ) { } public void execute ( OperationContext context , ModelNode operation ) throws OperationFailedException { final ModelNode domainModel = operation . get ( DOMAIN_MODEL ) ; <START_BUG> final ModelNode startRoot = Tools . readModel ( context . getRootResource ( ) ) ; <END_BUG> final Set < String > ourServerGroups = getOurServerGroups ( context ) ; final Map < String , Set < byte [ ] > > deploymentHashes = new HashMap < String , Set < byte [ ] > > ( ) ; final Set < String > relevantDeployments = new HashSet < String > ( ) ; final Set < byte [ ] > requiredContent = new HashSet < byte [ ] > ( ) ; final Resource rootResource = context . readResourceForUpdate ( EMPTY_ADDRESS ) ; clearDomain ( rootResource ) ; for ( final ModelNode resourceDescription : domainModel . asList ( ) ) { final PathAddress resourceAddress = PathAddress . pathAddress ( resourceDescription . require ( "domain-resource-address" ) ) ; if ( ignoredResourceRegistry . isResourceExcluded ( resourceAddress ) ) { continue ; } final Resource resource = getResource ( resourceAddress , rootResource , context ) ; if ( ( ( resourceAddress . size ( ) ) == 1 ) && ( resourceAddress . getElement ( 0 ) . getKey ( ) . equals ( EXTENSION ) ) ) { final String module = resourceAddress . getElement ( 0 ) . getValue ( ) ; if ( ! ( appliedExtensions . contains ( module ) ) ) { appliedExtensions . add ( module ) ; initializeExtension ( module ) ; } } resource . writeModel ( resourceDescription . get ( "domain-resource-model" ) ) ; if ( ( resourceAddress . size ( ) ) == 1 ) { PathElement pe = resourceAddress . getElement ( 0 ) ; String peKey = pe . getKey ( ) ; if ( peKey . equals ( DEPLOYMENT ) ) { ModelNode model = resource . getModel ( ) ; String id = resourceAddress . getElement ( 0 ) . getValue ( ) ; if ( model . hasDefined ( CONTENT ) ) { for ( ModelNode contentItem : model . get ( CONTENT ) . asList ( ) ) { if ( contentItem . hasDefined ( HASH ) ) { Set < byte [ ] > hashes = deploymentHashes . get ( id ) ; if ( hashes == null ) { hashes = new HashSet < byte [ ] > ( ) ; deploymentHashes . put ( id , hashes ) ; } hashes . add ( contentItem . get ( HASH ) . asBytes ( ) ) ; } } } } else if ( peKey . equals ( MANAGEMENT_CLIENT_CONTENT ) ) { ModelNode model = resource . getModel ( ) ; if ( model . hasDefined ( HASH ) ) { requiredContent . add ( model . get ( HASH ) . asBytes ( ) ) ; } } } else if ( ( ( ( ( resourceAddress . size ( ) ) == 2 ) && ( resourceAddress . getElement ( 0 ) . getKey ( ) . equals ( SERVER_GROUP ) ) ) && ( ourServerGroups . contains ( resourceAddress . getElement ( 0 ) . getValue ( ) ) ) ) && ( resourceAddress . getElement ( 1 ) . getKey ( ) . equals ( DEPLOYMENT ) ) ) { relevantDeployments . add ( resourceAddress . getElement ( 1 ) . getValue ( ) ) ; } } for ( String id : relevantDeployments ) { Set < byte [ ] > hashes = deploymentHashes . remove ( id ) ; if ( hashes != null ) { requiredContent . addAll ( hashes ) ; } } for ( byte [ ] hash : requiredContent ) { fileRepository . getDeploymentFiles ( hash ) ; } if ( ! ( context . isBooting ( ) ) ) { final Resource domainRootResource = context . readResourceForUpdate ( EMPTY_ADDRESS ) ; final ModelNode endRoot = Tools . readModel ( domainRootResource ) ; final Set < ServerIdentity > affectedServers = new HashSet < ServerIdentity > ( ) ; final ModelNode hostModel = endRoot . require ( HOST ) . asPropertyList ( ) . iterator ( ) . next ( ) . getValue ( ) ; final ModelNode existingHostModel = startRoot . require ( HOST ) . asPropertyList ( ) . iterator ( ) . next ( ) . getValue ( ) ; final Map < String , ProxyController > serverProxies = DomainServerUtils . getServerProxies ( localHostInfo . getLocalHostName ( ) , domainRootResource , context . getResourceRegistration ( ) ) ; final ModelNode startExtensions = startRoot . get ( EXTENSION ) ; final ModelNode finishExtensions = endRoot . get ( EXTENSION ) ; if ( ! ( startExtensions . equals ( finishExtensions ) ) ) { affectedServers . addAll ( DomainServerUtils . getAllRunningServers ( hostModel , localHostInfo . getLocalHostName ( ) , serverProxies ) ) ; } final ModelNode startPaths = startRoot . get ( PATH ) ; final ModelNode endPaths = endRoot . get ( PATH ) ; final Map < String , ModelNode > existingPaths = new HashMap < String , ModelNode > ( ) ; if ( startPaths . isDefined ( ) ) for ( Property property : startPaths . asPropertyList ( ) ) { existingPaths . put ( property . getName ( ) , property . getValue ( ) ) ; }

Fix:
final ModelNode startRoot = Tools . readModel ( context . readResourceFromRoot ( EMPTY_ADDRESS ) ) ;