Program: 167718
Project: 167718
Buggy source:
protected ModelNode remove(CommandContext ctx) throws CommandLineException {
  final ModelControllerClient client=ctx.getModelControllerClient();
  final ParsedCommandLine args=ctx.getParsedCommandLine();
  assertNotPresent(allServerGroups,args);
  final String name=this.name.getValue(args,true);
  if (name == null) {
    throw new CommandFormatException(this.name + "String_Node_Str");
  }
  final String contentStr=content.getValue(args);
  String deploymentStr=deployments.getValue(args);
  final String sgStr=serverGroups.getValue(args);
  final List<String> sg;
  if (sgStr == null) {
    if (allRelevantServerGroups.isPresent(args)) {
      sg=Util.getServerGroupsReferencingOverlay(name,client);
    }
 else {
      sg=null;
    }
  }
 else {
    sg=Arrays.asList(sgStr.split("String_Node_Str"));
    if (sg.isEmpty()) {
      throw new CommandFormatException(serverGroups.getFullName() + "String_Node_Str");
    }
  }
  final ModelNode composite=new ModelNode();
  composite.get(Util.OPERATION).set(Util.COMPOSITE);
  composite.get(Util.ADDRESS).setEmptyList();
  final ModelNode steps=composite.get(Util.STEPS);
  byte redeploy=this.redeployAffected.isPresent(args) ? REDEPLOY_ONLY_AFFECTED : REDEPLOY_NONE;
  if (!redeployAffected.isPresent(args)) {
    printWarning(ctx,client,name,contentStr,deploymentStr);
  }
  if (contentStr != null || deploymentStr == null && sg == null) {
    if (redeploy == REDEPLOY_ONLY_AFFECTED) {
      redeploy=REDEPLOY_ALL;
    }
    final List<String> contentList;
    if (contentStr == null) {
      contentList=loadContentFor(client,name);
    }
 else {
      contentList=java.util.Arrays.asList(contentStr.split("String_Node_Str"));
    }
    for (    String content : contentList) {
      final ModelNode op=new ModelNode();
      ModelNode addr=op.get(Util.ADDRESS);
      addr.add(Util.DEPLOYMENT_OVERLAY,name);
      addr.add(Util.CONTENT,content);
      op.get(Util.OPERATION).set(Util.REMOVE);
      steps.add(op);
    }
  }
  if (deploymentStr != null || contentStr == null) {
    if (ctx.isDomainMode()) {
      if (deploymentStr == null) {
        final List<String> groups=sg == null ? Util.getServerGroupsReferencingOverlay(name,client) : sg;
        for (        String group : groups) {
          addRemoveRedeployLinksSteps(ctx,client,steps,name,group,null,true,redeploy);
        }
      }
 else {
        if (ctx.isDomainMode() && sg == null) {
          throw new CommandFormatException(serverGroups.getFullName() + "String_Node_Str" + allRelevantServerGroups.getFullName()+ "String_Node_Str");
        }
        final List<String> links=Arrays.asList(deploymentStr.split("String_Node_Str"));
        for (        String group : sg) {
          addRemoveRedeployLinksSteps(ctx,client,steps,name,group,links,true,redeploy);
        }
      }
    }
 else {
      if (deploymentStr == null) {
        addRemoveRedeployLinksSteps(ctx,client,steps,name,null,null,true,redeploy);
      }
 else {
        final List<String> links=Arrays.asList(deploymentStr.split("String_Node_Str"));
        addRemoveRedeployLinksSteps(ctx,client,steps,name,null,links,true,redeploy);
      }
    }
  }
 else   if (redeploy == REDEPLOY_ALL) {
    if (ctx.isDomainMode()) {
      for (      String group : Util.getServerGroupsReferencingOverlay(name,client)) {
        addRemoveRedeployLinksSteps(ctx,client,steps,name,group,null,false,redeploy);
      }
    }
 else {
      addRemoveRedeployLinksSteps(ctx,client,steps,name,null,null,false,redeploy);
    }
  }
  if (contentStr == null && deploymentStr == null && sg == null) {
    final ModelNode op=new ModelNode();
    op.get(Util.ADDRESS).add(Util.DEPLOYMENT_OVERLAY,name);
    op.get(Util.OPERATION).set(Util.REMOVE);
    steps.add(op);
  }
  return composite;
}

Fixed version (ground truth):
protected ModelNode remove(CommandContext ctx) throws CommandLineException {
  final ModelControllerClient client=ctx.getModelControllerClient();
  final ParsedCommandLine args=ctx.getParsedCommandLine();
  assertNotPresent(allServerGroups,args);
  final String name=getName(ctx,false);
  final String contentStr=content.getValue(args);
  String deploymentStr=deployments.getValue(args);
  final String sgStr=serverGroups.getValue(args);
  final List<String> sg;
  if (sgStr == null) {
    if (allRelevantServerGroups.isPresent(args)) {
      sg=Util.getServerGroupsReferencingOverlay(name,client);
    }
 else {
      sg=null;
    }
  }
 else {
    sg=Arrays.asList(sgStr.split("String_Node_Str"));
    if (sg.isEmpty()) {
      throw new CommandFormatException(serverGroups.getFullName() + "String_Node_Str");
    }
  }
  final ModelNode composite=new ModelNode();
  composite.get(Util.OPERATION).set(Util.COMPOSITE);
  composite.get(Util.ADDRESS).setEmptyList();
  final ModelNode steps=composite.get(Util.STEPS);
  byte redeploy=this.redeployAffected.isPresent(args) ? REDEPLOY_ONLY_AFFECTED : REDEPLOY_NONE;
  if (!redeployAffected.isPresent(args)) {
    printWarning(ctx,client,name,contentStr,deploymentStr);
  }
  if (contentStr != null || deploymentStr == null && sg == null) {
    if (redeploy == REDEPLOY_ONLY_AFFECTED) {
      redeploy=REDEPLOY_ALL;
    }
    final List<String> contentList;
    if (contentStr == null) {
      contentList=loadContentFor(client,name);
    }
 else {
      contentList=java.util.Arrays.asList(contentStr.split("String_Node_Str"));
    }
    for (    String content : contentList) {
      final ModelNode op=new ModelNode();
      ModelNode addr=op.get(Util.ADDRESS);
      addr.add(Util.DEPLOYMENT_OVERLAY,name);
      addr.add(Util.CONTENT,content);
      op.get(Util.OPERATION).set(Util.REMOVE);
      steps.add(op);
    }
  }
  if (deploymentStr != null || contentStr == null) {
    if (ctx.isDomainMode()) {
      if (deploymentStr == null) {
        final List<String> groups=sg == null ? Util.getServerGroupsReferencingOverlay(name,client) : sg;
        for (        String group : groups) {
          addRemoveRedeployLinksSteps(ctx,client,steps,name,group,null,true,redeploy);
        }
      }
 else {
        if (ctx.isDomainMode() && sg == null) {
          throw new CommandFormatException(serverGroups.getFullName() + "String_Node_Str" + allRelevantServerGroups.getFullName()+ "String_Node_Str");
        }
        final List<String> links=Arrays.asList(deploymentStr.split("String_Node_Str"));
        for (        String group : sg) {
          addRemoveRedeployLinksSteps(ctx,client,steps,name,group,links,true,redeploy);
        }
      }
    }
 else {
      if (deploymentStr == null) {
        addRemoveRedeployLinksSteps(ctx,client,steps,name,null,null,true,redeploy);
      }
 else {
        final List<String> links=Arrays.asList(deploymentStr.split("String_Node_Str"));
        addRemoveRedeployLinksSteps(ctx,client,steps,name,null,links,true,redeploy);
      }
    }
  }
 else   if (redeploy == REDEPLOY_ALL) {
    if (ctx.isDomainMode()) {
      for (      String group : Util.getServerGroupsReferencingOverlay(name,client)) {
        addRemoveRedeployLinksSteps(ctx,client,steps,name,group,null,false,redeploy);
      }
    }
 else {
      addRemoveRedeployLinksSteps(ctx,client,steps,name,null,null,false,redeploy);
    }
  }
  if (contentStr == null && deploymentStr == null && sg == null) {
    final ModelNode op=new ModelNode();
    op.get(Util.ADDRESS).add(Util.DEPLOYMENT_OVERLAY,name);
    op.get(Util.OPERATION).set(Util.REMOVE);
    steps.add(op);
  }
  return composite;
}