Buggy code:
public class DomainDeploymentUtils implements Closeable { private final List < DomainDeploymentUtils . Deployment > deployments = new ArrayList < DomainDeploymentUtils . Deployment > ( ) ; private final ModelControllerClient client ; private boolean injectedClient = true ; public DomainDeploymentUtils ( ) throws UnknownHostException { } public DomainDeploymentUtils ( ModelControllerClient client ) throws UnknownHostException { } public DomainDeploymentUtils ( String archiveName , Package pkg ) throws UnknownHostException { } public DomainDeploymentUtils ( String archiveName , Package pkg , boolean show ) throws UnknownHostException { } public synchronized void addDeployment ( String archiveName , Package pkg ) { } public synchronized void addDeployment ( String archiveName , Package pkg , boolean show ) { } public synchronized void deploy ( ) throws IOException , InterruptedException , ExecutionException , DuplicateDeploymentNameException { } public synchronized void undeploy ( ) throws IOException { } public MBeanServerConnection getServerOneConnection ( ) throws Exception { } public String showServerOneJndi ( ) throws Exception { } public MBeanServerConnection getServerTwoConnection ( ) throws Exception { } public String showServerTwoJndi ( ) throws Exception { } @ Override public void close ( ) throws IOException { } private Set < String > getDeploymentNames ( ) throws IOException { } private ModelNode execute ( ModelNode op ) throws IOException { } private ModelNode execute ( Operation op ) throws IOException { } private static ModelNode getRolloutPlan ( ) { } private class Deployment { final String archiveName ; final Package pkg ; final JavaArchive archive ; final File realArchive ; public Deployment ( String archiveName , Package pkg , boolean show ) { } private void addFiles ( JavaArchive archive , File dir , ArchivePath dest ) { } public synchronized ModelNode addDeployment ( OperationBuilder context ) throws IOException { System . out . println ( ( "Deploying<seq2seq4repair_space>" + ( realArchive . getName ( ) ) ) ) ; Set < String > deployments = getDeploymentNames ( ) ; int index = context . getInputStreamCount ( ) ; context . addInputStream ( new FileInputStream ( realArchive ) ) ; ModelNode result = new ModelNode ( ) ; if ( deployments . contains ( archiveName ) ) { result . get ( "operation" ) . set ( "full-replace-deployment" ) ; result . get ( "name" ) . set ( archiveName ) ; <START_BUG> result . get ( "input-stream-index" ) . set ( index ) ; <END_BUG> } else { result . get ( "operation" ) . set ( "composite" ) ; ModelNode steps = result . get ( "steps" ) ; ModelNode add = steps . add ( ) ; add . get ( "operation" ) . set ( "add" ) ; add . get ( "address" ) . add ( "deployment" , archiveName ) ; add . get ( "content" ) . get ( 0 ) . get ( "input-stream-index" ) . set ( index ) ; ModelNode mainAdd = steps . add ( ) ; mainAdd . get ( "operation" ) . set ( "add" ) ; mainAdd . get ( "address" ) . add ( "server-group" , "main-server-group" ) ; mainAdd . get ( "address" ) . add ( "deployment" , archiveName ) ; ModelNode mainDeploy = steps . add ( ) ; mainDeploy . get ( "operation" ) . set ( "deploy" ) ; mainDeploy . get ( "address" ) . add ( "server-group" , "main-server-group" ) ; mainDeploy . get ( "address" ) . add ( "deployment" , archiveName ) ; ModelNode otherAdd = steps . add ( ) ; otherAdd . get ( "operation" ) . set ( "add" ) ; otherAdd . get ( "address" ) . add ( "server-group" , "other-server-group" ) ; otherAdd . get ( "address" ) . add ( "deployment" , archiveName ) ; ModelNode otherDeploy = steps . add ( ) ; otherDeploy . get ( "operation" ) . set ( "deploy" ) ; otherDeploy . get ( "address" ) . add ( "server-group" , "other-server-group" ) ; otherDeploy . get ( "address" ) . add ( "deployment" , archiveName ) ; } return result ; } public synchronized ModelNode removeDeployment ( ) { } private File getSourceMetaInfDir ( ) { } private File getOutputDir ( ) { } private void close ( Closeable c ) { } } }

Fix:
result . get ( "content" ) . get ( 0 ) . get ( "input-stream-index" ) . set ( index ) ;