Buggy code:
public class DeploymentReplaceHandler implements OperationStepHandler { public static final String OPERATION_NAME = REPLACE_DEPLOYMENT ; private final ContentRepository contentRepository ; private final AbstractVaultReader vaultReader ; protected DeploymentReplaceHandler ( ContentRepository contentRepository , final AbstractVaultReader vaultReader ) { } public static DeploymentReplaceHandler create ( ContentRepository contentRepository , final AbstractVaultReader vaultReader ) { } public void execute ( OperationContext context , ModelNode operation ) throws OperationFailedException { for ( AttributeDefinition def : REPLACE_DEPLOYMENT_ATTRIBUTES . values ( ) ) { def . validateOperation ( operation ) ; } String name = REPLACE_DEPLOYMENT_ATTRIBUTES . get ( NAME ) . resolveModelAttribute ( context , operation ) . asString ( ) ; String toReplace = REPLACE_DEPLOYMENT_ATTRIBUTES . get ( TO_REPLACE ) . resolveModelAttribute ( context , operation ) . asString ( ) ; if ( name . equals ( toReplace ) ) { throw MESSAGES . cannotReplaceDeployment ( DeploymentReplaceHandler . OPERATION_NAME , NAME , TO_REPLACE , DeploymentRedeployHandler . OPERATION_NAME , DeploymentFullReplaceHandler . OPERATION_NAME ) ; } final PathElement deployPath = PathElement . pathElement ( DEPLOYMENT , name ) ; final PathElement replacePath = PathElement . pathElement ( DEPLOYMENT , toReplace ) ; final Resource root = context . readResource ( EMPTY_ADDRESS ) ; if ( ! ( root . hasChild ( replacePath ) ) ) { throw MESSAGES . noSuchDeployment ( toReplace ) ; } final ModelNode replaceNode = context . readResourceForUpdate ( PathAddress . pathAddress ( replacePath ) ) . getModel ( ) ; final String replacedName = REPLACE_DEPLOYMENT_ATTRIBUTES . get ( RUNTIME_NAME ) . resolveModelAttribute ( context , replaceNode ) . asString ( ) ; ModelNode deployNode ; String runtimeName ; if ( ! ( root . hasChild ( deployPath ) ) ) { if ( ! ( operation . hasDefined ( CONTENT ) ) ) { throw MESSAGES . noSuchDeployment ( name ) ; } final ModelNode content = operation . require ( CONTENT ) ; final ModelNode contentItemNode = content . require ( 0 ) ; if ( contentItemNode . hasDefined ( HASH ) ) { byte [ ] hash = contentItemNode . require ( HASH ) . asBytes ( ) ; addFromHash ( hash ) ; } else { } runtimeName = ( operation . hasDefined ( RUNTIME_NAME ) ) ? REPLACE_DEPLOYMENT_ATTRIBUTES . get ( RUNTIME_NAME ) . resolveModelAttribute ( context , operation ) . asString ( ) : replacedName ; final Resource deployResource = context . createResource ( PathAddress . pathAddress ( deployPath ) ) ; deployNode = deployResource . getModel ( ) ; deployNode . get ( RUNTIME_NAME ) . set ( runtimeName ) ; deployNode . get ( PERSISTENT ) . set ( true ) ; deployNode . get ( CONTENT ) . set ( content ) ; } else { deployNode = context . readResourceForUpdate ( PathAddress . pathAddress ( deployPath ) ) . getModel ( ) ; if ( ENABLED . resolveModelAttribute ( context , deployNode ) . asBoolean ( ) ) { throw MESSAGES . deploymentAlreadyStarted ( toReplace ) ; } runtimeName = deployNode . require ( RUNTIME_NAME ) . asString ( ) ; } deployNode . get ( ENABLED . getName ( ) ) . set ( true ) ; replaceNode . get ( ENABLED . getName ( ) ) . set ( false ) ; final DeploymentHandlerUtil [ ] contents = DeploymentHandlerUtils . getContents ( deployNode . require ( CONTENT ) ) ; DeploymentHandlerUtil . replace ( context , replaceNode , runtimeName , name , replacedName , vaultReader , contents ) ; <START_BUG> context . completeStep ( ) ; <END_BUG> } protected void addFromHash ( byte [ ] hash ) throws OperationFailedException { } }

Fix:
context . stepCompleted ( ) ;