Buggy code:
public class DeploymentReplaceHandler implements NewStepHandler , DescriptionProvider { public static final String OPERATION_NAME = REPLACE_DEPLOYMENT ; static final ModelNode getOperation ( ModelNode address ) { } private final ContentRepository contentRepository ; private final ParametersValidator validator = new ParametersValidator ( ) ; private final ParametersValidator unmanagedContentValidator = new ParametersValidator ( ) ; private final ParametersValidator managedContentValidator = new ParametersValidator ( ) ; public DeploymentReplaceHandler ( ContentRepository contentRepository ) { } @ Override public ModelNode getModelDescription ( Locale locale ) { } public void execute ( NewOperationContext context , ModelNode operation ) throws OperationFailedException { validator . validate ( operation ) ; ModelNode deployments = context . readModelForUpdate ( EMPTY_ADDRESS ) . get ( DEPLOYMENT ) ; String name = operation . require ( NAME ) . asString ( ) ; String toReplace = operation . require ( TO_REPLACE ) . asString ( ) ; if ( name . equals ( toReplace ) ) { throw DeploymentReplaceHandler . operationFailed ( String . format ( ( "Cannot<seq2seq4repair_space>use<seq2seq4repair_space>%s<seq2seq4repair_space>with<seq2seq4repair_space>the<seq2seq4repair_space>same<seq2seq4repair_space>value<seq2seq4repair_space>for<seq2seq4repair_space>parameters<seq2seq4repair_space>%s<seq2seq4repair_space>and<seq2seq4repair_space>%s.<seq2seq4repair_space>" + "Use<seq2seq4repair_space>%s<seq2seq4repair_space>to<seq2seq4repair_space>redeploy<seq2seq4repair_space>the<seq2seq4repair_space>same<seq2seq4repair_space>content<seq2seq4repair_space>or<seq2seq4repair_space>%s<seq2seq4repair_space>to<seq2seq4repair_space>replace<seq2seq4repair_space>content<seq2seq4repair_space>with<seq2seq4repair_space>a<seq2seq4repair_space>new<seq2seq4repair_space>version<seq2seq4repair_space>with<seq2seq4repair_space>the<seq2seq4repair_space>same<seq2seq4repair_space>name." ) , DeploymentReplaceHandler . OPERATION_NAME , NAME , TO_REPLACE , DeploymentRedeployHandler . OPERATION_NAME , DeploymentFullReplaceHandler . OPERATION_NAME ) ) ; } ModelNode replaceNode = ( deployments . hasDefined ( toReplace ) ) ? deployments . get ( toReplace ) : null ; if ( replaceNode == null ) { throw DeploymentReplaceHandler . operationFailed ( String . format ( "No<seq2seq4repair_space>deployment<seq2seq4repair_space>with<seq2seq4repair_space>name<seq2seq4repair_space>%s<seq2seq4repair_space>found" , toReplace ) ) ; } final String replacedName = replaceNode . require ( RUNTIME_NAME ) . asString ( ) ; ModelNode deployNode = ( deployments . hasDefined ( name ) ) ? deployments . get ( name ) : null ; if ( deployNode == null ) { if ( ! ( operation . hasDefined ( CONTENT ) ) ) { throw DeploymentReplaceHandler . operationFailed ( String . format ( "No<seq2seq4repair_space>deployment<seq2seq4repair_space>with<seq2seq4repair_space>name<seq2seq4repair_space>%s<seq2seq4repair_space>found" , name ) ) ; } final ModelNode content = operation . require ( CONTENT ) . clone ( ) ; final ModelNode contentItemNode = content . require ( 0 ) ; if ( contentItemNode . hasDefined ( HASH ) ) { managedContentValidator . validate ( contentItemNode ) ; byte [ ] 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 ) ) ; } else { unmanagedContentValidator . validate ( contentItemNode ) ; } final String runtimeName = ( operation . hasDefined ( RUNTIME_NAME ) ) ? operation . get ( RUNTIME_NAME ) . asString ( ) : replacedName ; deployNode = new ModelNode ( ) ; deployNode . get ( RUNTIME_NAME ) . set ( runtimeName ) ; deployNode . get ( CONTENT ) . set ( content ) ; deployments . get ( name ) . set ( deployNode ) ; } else if ( deployNode . get ( ENABLED ) . asBoolean ( ) ) { throw DeploymentReplaceHandler . operationFailed ( String . format ( "Deployment<seq2seq4repair_space>%s<seq2seq4repair_space>is<seq2seq4repair_space>already<seq2seq4repair_space>started" , toReplace ) ) ; } deployNode . get ( ENABLED ) . set ( true ) ; replaceNode . get ( ENABLED ) . set ( false ) ; final String runtimeName = deployNode . require ( RUNTIME_NAME ) . asString ( ) ; final DeploymentHandlerUtil [ ] contents = AbstractDeploymentHandler . getContents ( deployNode . require ( CONTENT ) ) ; <START_BUG> DeploymentHandlerUtil . replace ( context , runtimeName , name , replacedName , contents ) ; <END_BUG> context . completeStep ( ) ; } private static OperationFailedException operationFailed ( String msg ) { } }

Fix:
DeploymentHandlerUtil . replace ( context , replaceNode , runtimeName , name , replacedName , contents ) ;