Buggy code:
public class DeploymentFullReplaceHandler implements NewStepHandler , DescriptionProvider { public static final String OPERATION_NAME = FULL_REPLACE_DEPLOYMENT ; private final ContentRepository contentRepository ; private final ParametersValidator validator = new ParametersValidator ( ) ; private final ParametersValidator unmanagedContentValidator = new ParametersValidator ( ) ; private final ParametersValidator managedContentValidator = new ParametersValidator ( ) ; public DeploymentFullReplaceHandler ( final ContentRepository contentRepository ) { } @ Override public ModelNode getModelDescription ( Locale locale ) { } public void execute ( NewOperationContext context , ModelNode operation ) throws OperationFailedException { validator . validate ( operation ) ; String name = operation . require ( NAME ) . asString ( ) ; ModelNode rootModel = context . readModelForUpdate ( EMPTY_ADDRESS ) ; ModelNode deployments = rootModel . get ( DEPLOYMENT ) ; ModelNode replaceNode = ( deployments . hasDefined ( name ) ) ? deployments . get ( name ) : null ; if ( replaceNode == null ) { throw AbstractDeploymentHandler . createFailureException ( "No<seq2seq4repair_space>deployment<seq2seq4repair_space>with<seq2seq4repair_space>name<seq2seq4repair_space>%s<seq2seq4repair_space>found" , name ) ; } String replacedRuntimeName = replaceNode . require ( RUNTIME_NAME ) . asString ( ) ; String runtimeName = ( operation . hasDefined ( RUNTIME_NAME ) ) ? operation . get ( RUNTIME_NAME ) . asString ( ) : replaceNode . require ( RUNTIME_NAME ) . asString ( ) ; final byte [ ] hash ; final ModelNode content = operation . require ( CONTENT ) . clone ( ) ; final DeploymentHandlerUtil . ContentItem contentItem ; final ModelNode contentItemNode = content . require ( 0 ) ; if ( contentItemNode . hasDefined ( HASH ) ) { managedContentValidator . validate ( contentItemNode ) ; hash = contentItemNode . require ( HASH ) . asBytes ( ) ; if ( ! ( contentRepository . hasContent ( hash ) ) ) throw AbstractDeploymentHandler . createFailureException ( "No<seq2seq4repair_space>deployment<seq2seq4repair_space>content<seq2seq4repair_space>with<seq2seq4repair_space>hash<seq2seq4repair_space>%s<seq2seq4repair_space>is<seq2seq4repair_space>available<seq2seq4repair_space>in<seq2seq4repair_space>the<seq2seq4repair_space>deployment<seq2seq4repair_space>content<seq2seq4repair_space>repository." , HashUtil . bytesToHexString ( hash ) ) ; contentItem = new DeploymentHandlerUtil . ContentItem ( hash ) ; } else if ( AbstractDeploymentHandler . hasValidContentAdditionParameterDefined ( contentItemNode ) ) { InputStream in = AbstractDeploymentHandler . getInputStream ( context , contentItemNode ) ; try { try { hash = contentRepository . addContent ( in ) ; } catch ( IOException e ) { throw AbstractDeploymentHandler . createFailureException ( e . toString ( ) ) ; } } finally { StreamUtils . safeClose ( in ) ; } contentItemNode . get ( HASH ) . set ( hash ) ; contentItem = new DeploymentHandlerUtil . ContentItem ( hash ) ; } else { unmanagedContentValidator . validate ( contentItemNode ) ; final String path = contentItemNode . require ( PATH ) . asString ( ) ; final String relativeTo = AbstractDeploymentHandler . asString ( contentItemNode , RELATIVE_TO ) ; final boolean archive = contentItemNode . require ( ARCHIVE ) . asBoolean ( ) ; contentItem = new DeploymentHandlerUtil . ContentItem ( path , relativeTo , archive ) ; } boolean start = replaceNode . get ( ENABLED ) . asBoolean ( ) ; ModelNode deployNode = new ModelNode ( ) ; deployNode . get ( NAME ) . set ( name ) ; deployNode . get ( RUNTIME_NAME ) . set ( runtimeName ) ; deployNode . get ( CONTENT ) . set ( content ) ; deployNode . get ( ENABLED ) . set ( start ) ; deployments . get ( name ) . set ( deployNode ) ; DeploymentFullReplaceHandler . removeContentAdditions ( replaceNode . require ( CONTENT ) ) ; if ( start ) { <START_BUG> DeploymentHandlerUtil . replace ( context , runtimeName , name , replacedRuntimeName , contentItem ) ; <END_BUG> } context . completeStep ( ) ; } private static void removeAttributes ( final ModelNode node , final Iterable < String > attributeNames ) { } private static void removeContentAdditions ( final ModelNode content ) { } }

Fix:
DeploymentHandlerUtil . replace ( context , replaceNode , runtimeName , name , replacedRuntimeName , contentItem ) ;