Buggy code:
public class DeploymentFullReplaceHandler implements ModelUpdateOperationHandler , DescriptionProvider { public static final String OPERATION_NAME = "full-replace-deployment" ; static final ModelNode getOperation ( ModelNode address ) { } private final DeploymentRepository deploymentRepository ; private final ParametersValidator validator = new ParametersValidator ( ) ; public DeploymentFullReplaceHandler ( final DeploymentRepository deploymentRepository ) { } @ Override public ModelNode getModelDescription ( Locale locale ) { } @ Override public OperationResult execute ( OperationContext context , ModelNode operation , ResultHandler resultHandler ) throws OperationFailedException { validator . validate ( operation ) ; String name = operation . require ( NAME ) . asString ( ) ; String runtimeName = ( operation . hasDefined ( RUNTIME_NAME ) ) ? operation . get ( RUNTIME_NAME ) . asString ( ) : name ; byte [ ] hash ; if ( ( operation . hasDefined ( INPUT_STREAM_INDEX ) ) && ( operation . hasDefined ( HASH ) ) ) { throw new OperationFailedException ( new ModelNode ( ) . set ( "Can't<seq2seq4repair_space>pass<seq2seq4repair_space>in<seq2seq4repair_space>both<seq2seq4repair_space>an<seq2seq4repair_space>input-stream-index<seq2seq4repair_space>and<seq2seq4repair_space>a<seq2seq4repair_space>hash" ) ) ; } else if ( operation . hasDefined ( INPUT_STREAM_INDEX ) ) { InputStream in = getContents ( context , operation ) ; try { <START_BUG> hash = deploymentRepository . addDeploymentContent ( name , runtimeName , in ) ; <END_BUG> } catch ( IOException e ) { throw new OperationFailedException ( new ModelNode ( ) . set ( e . toString ( ) ) ) ; } operation . remove ( INPUT_STREAM_INDEX ) ; operation . get ( HASH ) . set ( hash ) ; } else if ( operation . hasDefined ( HASH ) ) { hash = operation . get ( HASH ) . asBytes ( ) ; if ( ! ( deploymentRepository . hasDeploymentContent ( hash ) ) ) { throw new OperationFailedException ( new ModelNode ( ) . set ( String . format ( "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 { throw new OperationFailedException ( new ModelNode ( ) . set ( "Neither<seq2seq4repair_space>an<seq2seq4repair_space>attachment<seq2seq4repair_space>or<seq2seq4repair_space>a<seq2seq4repair_space>hash<seq2seq4repair_space>were<seq2seq4repair_space>passed<seq2seq4repair_space>in" ) ) ; } ModelNode rootModel = context . getSubModel ( ) ; ModelNode deployments = rootModel . get ( DEPLOYMENT ) ; ModelNode replaceNode = ( deployments . hasDefined ( name ) ) ? deployments . get ( name ) : null ; if ( replaceNode == null ) { throw new OperationFailedException ( new ModelNode ( ) . set ( String . format ( "No<seq2seq4repair_space>deployment<seq2seq4repair_space>with<seq2seq4repair_space>name<seq2seq4repair_space>%s<seq2seq4repair_space>found" , name ) ) ) ; } ModelNode deployNode = new ModelNode ( ) ; deployNode . get ( NAME ) . set ( name ) ; deployNode . get ( RUNTIME_NAME ) . set ( runtimeName ) ; deployNode . get ( HASH ) . set ( hash ) ; deployments . get ( name ) . set ( deployNode ) ; if ( rootModel . hasDefined ( SERVER_GROUP ) ) { for ( Property server : rootModel . get ( SERVER_GROUP ) . asPropertyList ( ) ) { ModelNode serverConfig = server . getValue ( ) ; if ( ( serverConfig . hasDefined ( DEPLOYMENT ) ) && ( serverConfig . get ( DEPLOYMENT ) . hasDefined ( name ) ) ) { ModelNode groupDeployNode = serverConfig . get ( DEPLOYMENT , name ) ; groupDeployNode . get ( RUNTIME_NAME ) . set ( runtimeName ) ; groupDeployNode . get ( HASH ) . set ( hash ) ; } } } ModelNode compensatingOp = operation . clone ( ) ; compensatingOp . get ( RUNTIME_NAME ) . set ( replaceNode . get ( RUNTIME_NAME ) . asString ( ) ) ; compensatingOp . get ( HASH ) . set ( replaceNode . get ( HASH ) . asBytes ( ) ) ; if ( operation . hasDefined ( INPUT_STREAM_INDEX ) ) { operation . remove ( INPUT_STREAM_INDEX ) ; } resultHandler . handleResultComplete ( ) ; return new org . jboss . as . controller . BasicOperationResult ( compensatingOp ) ; } private InputStream getContents ( OperationContext context , ModelNode operation ) { } }

Fix:
hash = deploymentRepository . addDeploymentContent ( in ) ;