Buggy code:
public class DeploymentAddHandler implements ModelAddOperationHandler , DescriptionProvider { public static final String OPERATION_NAME = ADD ; static final ModelNode getOperation ( ModelNode address , ModelNode state ) { } private final DeploymentRepository deploymentRepository ; private final ParametersValidator validator = new ParametersValidator ( ) ; public DeploymentAddHandler ( final DeploymentRepository deploymentRepository ) { } @ Override public ModelNode getModelDescription ( Locale locale ) { } @ Override public OperationResult execute ( OperationContext context , ModelNode operation , ResultHandler resultHandler ) throws OperationFailedException { validator . validate ( operation ) ; ModelNode opAddr = operation . get ( OP_ADDR ) ; PathAddress address = PathAddress . pathAddress ( opAddr ) ; String name = address . getLastElement ( ) . getValue ( ) ; 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 { try { <START_BUG> hash = deploymentRepository . addDeploymentContent ( name , runtimeName , in ) ; <END_BUG> } catch ( IOException e ) { throw new OperationFailedException ( new ModelNode ( ) . set ( e . toString ( ) ) ) ; } } finally { StreamUtils . safeClose ( in ) ; } operation . remove ( INPUT_STREAM_INDEX ) ; operation . get ( HASH ) . set ( hash ) ; } else if ( operation . hasDefined ( HASH ) ) { hash = operation . get ( HASH ) . asBytes ( ) ; } else { throw new OperationFailedException ( new ModelNode ( ) . set ( "Neither<seq2seq4repair_space>an<seq2seq4repair_space>attachment<seq2seq4repair_space>nor<seq2seq4repair_space>a<seq2seq4repair_space>hash<seq2seq4repair_space>were<seq2seq4repair_space>passed<seq2seq4repair_space>in" ) ) ; } if ( deploymentRepository . hasDeploymentContent ( hash ) ) { ModelNode subModel = context . getSubModel ( ) ; subModel . get ( NAME ) . set ( name ) ; subModel . get ( RUNTIME_NAME ) . set ( runtimeName ) ; subModel . get ( HASH ) . set ( hash ) ; } else { 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 ) ) ) ) ; } resultHandler . handleResultComplete ( ) ; return new org . jboss . as . controller . BasicOperationResult ( Util . getResourceRemoveOperation ( operation . get ( OP_ADDR ) ) ) ; } private InputStream getContents ( OperationContext context , ModelNode operation ) { } }

Fix:
hash = deploymentRepository . addDeploymentContent ( in ) ;