Program: 167707
Project: 167707
Buggy source:
@Override public ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException {
  final ModelNode composite=new ModelNode();
  composite.get(Util.OPERATION).set(Util.COMPOSITE);
  composite.get(Util.ADDRESS).setEmptyList();
  final ModelNode steps=composite.get(Util.STEPS);
  final ParsedCommandLine args=ctx.getParsedCommandLine();
  final String name=this.name.getValue(args);
  boolean keepContent=this.keepContent.isPresent(args);
  final boolean allRelevantServerGroups=this.allRelevantServerGroups.isPresent(args);
  final String serverGroupsStr=this.serverGroups.getValue(args);
  final String path=this.path.getValue(args);
  final File f;
  if (path != null) {
    f=new File(path);
    if (!f.exists()) {
      throw new OperationFormatException("String_Node_Str" + f.getAbsolutePath() + "String_Node_Str");
    }
    if (!isCliArchive(f)) {
      throw new OperationFormatException("String_Node_Str" + f.getAbsolutePath() + "String_Node_Str");
    }
  }
 else {
    f=null;
  }
  if (isCliArchive(f)) {
    if (name != null) {
      throw new OperationFormatException(this.name.getFullName() + "String_Node_Str");
    }
    if (serverGroupsStr != null || allRelevantServerGroups) {
      throw new OperationFormatException(this.serverGroups.getFullName() + "String_Node_Str" + this.allRelevantServerGroups.getFullName()+ "String_Node_Str");
    }
    if (keepContent) {
      throw new OperationFormatException(this.keepContent.getFullName() + "String_Node_Str");
    }
    TempFileProvider tempFileProvider;
    MountHandle root;
    try {
      tempFileProvider=TempFileProvider.create("String_Node_Str",Executors.newSingleThreadScheduledExecutor(),true);
      root=extractArchive(f,tempFileProvider);
    }
 catch (    IOException e) {
      throw new OperationFormatException("String_Node_Str" + f.getAbsolutePath() + "String_Node_Str");
    }
    final File currentDir=ctx.getCurrentDir();
    ctx.setCurrentDir(root.getMountSource());
    String holdbackBatch=activateNewBatch(ctx);
    try {
      String script=this.script.getValue(args);
      if (script == null) {
        script="String_Node_Str";
      }
      File scriptFile=new File(ctx.getCurrentDir(),script);
      if (!scriptFile.exists()) {
        throw new CommandFormatException("String_Node_Str" + script + "String_Node_Str"+ f.getAbsolutePath()+ "String_Node_Str");
      }
      BufferedReader reader=null;
      try {
        reader=Files.newBufferedReader(scriptFile.toPath(),StandardCharsets.UTF_8);
        String line=reader.readLine();
        while (!ctx.isTerminated() && line != null) {
          ctx.handle(line);
          line=reader.readLine();
        }
      }
 catch (      FileNotFoundException e) {
        throw new CommandFormatException("String_Node_Str" + script + "String_Node_Str"+ f.getAbsolutePath()+ "String_Node_Str");
      }
catch (      IOException e) {
        throw new CommandFormatException("String_Node_Str" + scriptFile.getName() + "String_Node_Str"+ e.getMessage(),e);
      }
catch (      CommandLineException e) {
        throw new CommandFormatException(e.getMessage(),e);
      }
 finally {
        if (reader != null) {
          try {
            reader.close();
          }
 catch (          IOException e) {
          }
        }
      }
      return ctx.getBatchManager().getActiveBatch().toRequest();
    }
  finally {
      ctx.setCurrentDir(currentDir);
      discardBatch(ctx,holdbackBatch);
      VFSUtils.safeClose(root,tempFileProvider);
    }
  }
  if (name == null) {
    throw new OperationFormatException("String_Node_Str");
  }
  final ModelControllerClient client=ctx.getModelControllerClient();
  DefaultOperationRequestBuilder builder;
  final List<String> deploymentNames;
  if (name.indexOf('*') < 0) {
    deploymentNames=Collections.singletonList(name);
  }
 else {
    deploymentNames=Util.getMatchingDeployments(client,name,null);
    if (deploymentNames.isEmpty()) {
      throw new CommandFormatException("String_Node_Str" + name);
    }
  }
  for (  String deploymentName : deploymentNames) {
    final List<String> serverGroups;
    if (ctx.isDomainMode()) {
      if (allRelevantServerGroups) {
        if (keepContent) {
          serverGroups=Util.getAllEnabledServerGroups(deploymentName,client);
        }
 else {
          try {
            serverGroups=Util.getServerGroupsReferencingDeployment(deploymentName,client);
          }
 catch (          CommandLineException e) {
            throw new CommandFormatException("String_Node_Str",e);
          }
        }
      }
 else {
        if (serverGroupsStr == null) {
          serverGroups=Collections.emptyList();
        }
 else {
          serverGroups=Arrays.asList(serverGroupsStr.split("String_Node_Str"));
        }
      }
      if (serverGroups.isEmpty()) {
        if (keepContent) {
          throw new OperationFormatException("String_Node_Str");
        }
      }
 else {
        if (!keepContent) {
          try {
            List<String> sg=Util.getServerGroupsReferencingDeployment(deploymentName,client);
            keepContent=!serverGroups.containsAll(sg);
          }
 catch (          CommandLineException e) {
            throw new CommandFormatException("String_Node_Str",e);
          }
        }
        for (        String group : serverGroups) {
          ModelNode groupStep=Util.configureDeploymentOperation(Util.UNDEPLOY,deploymentName,group);
          steps.add(groupStep);
          if (!keepContent) {
            groupStep=Util.configureDeploymentOperation(Util.REMOVE,deploymentName,group);
            steps.add(groupStep);
          }
        }
      }
    }
 else {
      if (Util.isDeployedAndEnabledInStandalone(deploymentName,client)) {
        builder=new DefaultOperationRequestBuilder();
        builder.setOperationName(Util.UNDEPLOY);
        builder.addNode(Util.DEPLOYMENT,deploymentName);
        steps.add(builder.buildRequest());
      }
    }
  }
  if (!keepContent) {
    for (    String deploymentName : deploymentNames) {
      builder=new DefaultOperationRequestBuilder();
      builder.setOperationName(Util.REMOVE);
      builder.addNode(Util.DEPLOYMENT,deploymentName);
      steps.add(builder.buildRequest());
    }
  }
  return composite;
}

Fixed version (ground truth):
@Override public ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException {
  final ModelNode composite=new ModelNode();
  composite.get(Util.OPERATION).set(Util.COMPOSITE);
  composite.get(Util.ADDRESS).setEmptyList();
  final ModelNode steps=composite.get(Util.STEPS);
  final ParsedCommandLine args=ctx.getParsedCommandLine();
  final String name=this.name.getValue(args);
  boolean keepContent=this.keepContent.isPresent(args);
  final boolean allRelevantServerGroups=this.allRelevantServerGroups.isPresent(args);
  final String serverGroupsStr=this.serverGroups.getValue(args);
  final String path=this.path.getValue(args);
  final File f;
  if (path != null) {
    f=new File(path);
    if (!f.exists()) {
      throw new OperationFormatException("String_Node_Str" + f.getAbsolutePath() + "String_Node_Str");
    }
    if (!isCliArchive(f)) {
      throw new OperationFormatException("String_Node_Str" + f.getAbsolutePath() + "String_Node_Str");
    }
  }
 else {
    f=null;
  }
  if (isCliArchive(f)) {
    if (name != null) {
      throw new OperationFormatException(this.name.getFullName() + "String_Node_Str");
    }
    if (serverGroupsStr != null || allRelevantServerGroups) {
      throw new OperationFormatException(this.serverGroups.getFullName() + "String_Node_Str" + this.allRelevantServerGroups.getFullName()+ "String_Node_Str");
    }
    if (keepContent) {
      throw new OperationFormatException(this.keepContent.getFullName() + "String_Node_Str");
    }
    TempFileProvider tempFileProvider;
    MountHandle root;
    try {
      tempFileProvider=TempFileProvider.create("String_Node_Str",Executors.newSingleThreadScheduledExecutor(),true);
      root=extractArchive(f,tempFileProvider);
    }
 catch (    IOException e) {
      throw new OperationFormatException("String_Node_Str" + f.getAbsolutePath() + "String_Node_Str");
    }
    final File currentDir=ctx.getCurrentDir();
    ctx.setCurrentDir(root.getMountSource());
    String holdbackBatch=activateNewBatch(ctx);
    try {
      String script=this.script.getValue(args);
      if (script == null) {
        script="String_Node_Str";
      }
      File scriptFile=new File(ctx.getCurrentDir(),script);
      if (!scriptFile.exists()) {
        throw new CommandFormatException("String_Node_Str" + script + "String_Node_Str"+ f.getAbsolutePath()+ "String_Node_Str");
      }
      try (BufferedReader reader=new BufferedReader(new FileReader(scriptFile))){
        String line=reader.readLine();
        while (!ctx.isTerminated() && line != null) {
          ctx.handle(line);
          line=reader.readLine();
        }
      }
 catch (      FileNotFoundException e) {
        throw new CommandFormatException("String_Node_Str" + script + "String_Node_Str"+ f.getAbsolutePath()+ "String_Node_Str");
      }
catch (      IOException e) {
        throw new CommandFormatException("String_Node_Str" + scriptFile.getName() + "String_Node_Str"+ e.getMessage(),e);
      }
catch (      CommandLineException e) {
        throw new CommandFormatException(e.getMessage(),e);
      }
      return ctx.getBatchManager().getActiveBatch().toRequest();
    }
  finally {
      ctx.setCurrentDir(currentDir);
      discardBatch(ctx,holdbackBatch);
      VFSUtils.safeClose(root,tempFileProvider);
    }
  }
  if (name == null) {
    throw new OperationFormatException("String_Node_Str");
  }
  final ModelControllerClient client=ctx.getModelControllerClient();
  DefaultOperationRequestBuilder builder;
  final List<String> deploymentNames;
  if (name.indexOf('*') < 0) {
    deploymentNames=Collections.singletonList(name);
  }
 else {
    deploymentNames=Util.getMatchingDeployments(client,name,null);
    if (deploymentNames.isEmpty()) {
      throw new CommandFormatException("String_Node_Str" + name);
    }
  }
  for (  String deploymentName : deploymentNames) {
    final List<String> serverGroups;
    if (ctx.isDomainMode()) {
      if (allRelevantServerGroups) {
        if (keepContent) {
          serverGroups=Util.getAllEnabledServerGroups(deploymentName,client);
        }
 else {
          try {
            serverGroups=Util.getServerGroupsReferencingDeployment(deploymentName,client);
          }
 catch (          CommandLineException e) {
            throw new CommandFormatException("String_Node_Str",e);
          }
        }
      }
 else {
        if (serverGroupsStr == null) {
          serverGroups=Collections.emptyList();
        }
 else {
          serverGroups=Arrays.asList(serverGroupsStr.split("String_Node_Str"));
        }
      }
      if (serverGroups.isEmpty()) {
        if (keepContent) {
          throw new OperationFormatException("String_Node_Str");
        }
      }
 else {
        if (!keepContent) {
          try {
            List<String> sg=Util.getServerGroupsReferencingDeployment(deploymentName,client);
            keepContent=!serverGroups.containsAll(sg);
          }
 catch (          CommandLineException e) {
            throw new CommandFormatException("String_Node_Str",e);
          }
        }
        for (        String group : serverGroups) {
          ModelNode groupStep=Util.configureDeploymentOperation(Util.UNDEPLOY,deploymentName,group);
          steps.add(groupStep);
          if (!keepContent) {
            groupStep=Util.configureDeploymentOperation(Util.REMOVE,deploymentName,group);
            steps.add(groupStep);
          }
        }
      }
    }
 else {
      if (Util.isDeployedAndEnabledInStandalone(deploymentName,client)) {
        builder=new DefaultOperationRequestBuilder();
        builder.setOperationName(Util.UNDEPLOY);
        builder.addNode(Util.DEPLOYMENT,deploymentName);
        steps.add(builder.buildRequest());
      }
    }
  }
  if (!keepContent) {
    for (    String deploymentName : deploymentNames) {
      builder=new DefaultOperationRequestBuilder();
      builder.setOperationName(Util.REMOVE);
      builder.addNode(Util.DEPLOYMENT,deploymentName);
      steps.add(builder.buildRequest());
    }
  }
  return composite;
}