Program: 29426
Project: 29426
Buggy source:
/** 
 * <p>Execute the passed command on targeted remote instances. The list of remote instances is usually retrieved from the passed parameters (with a "target" parameter for instance) or from the configuration. <p>Each remote execution must return a different ActionReport so the user or framework can get feedback on the success or failure or such executions.
 * @param commandName the command to execute
 * @param context the original command context
 * @param parameters the parameters passed to the original local command
 * @return an array of @{link org.glassfish.api.ActionReport} for each remoteexecution status. 
 */
@Override public ActionReport.ExitCode execute(String commandName,AdminCommand command,AdminCommandContext context,ParameterMap parameters){
  CommandModel model;
  try {
    CommandModelProvider c=(CommandModelProvider)command;
    model=c.getModel();
  }
 catch (  ClassCastException e) {
    model=new CommandModelImpl(command.getClass());
  }
  org.glassfish.api.admin.ExecuteOn clAnnotation=model.getClusteringAttributes();
  List<RuntimeType> runtimeTypes=new ArrayList<RuntimeType>();
@ExecuteOn final class DefaultExecuteOn {
  }
  if (clAnnotation == null) {
    clAnnotation=DefaultExecuteOn.class.getAnnotation(ExecuteOn.class);
  }
  if (clAnnotation.value().length == 0) {
    runtimeTypes.add(RuntimeType.DAS);
    runtimeTypes.add(RuntimeType.INSTANCE);
  }
 else {
    runtimeTypes.addAll(Arrays.asList(clAnnotation.value()));
  }
  String targetName=parameters.getOne("String_Node_Str");
  if (targetName == null)   targetName="String_Node_Str";
  if ((runtimeTypes.contains(RuntimeType.ALL)) || ((!CommandTarget.DAS.isValid(habitat,targetName)) && (!CommandTarget.DOMAIN.isValid(habitat,targetName)))) {
    if (targetService.isCluster(targetName) && !runtimeTypes.contains(RuntimeType.ALL)) {
      String dynRecfg=targetService.getClusterConfig(targetName).getDynamicReconfigurationEnabled();
      if (Boolean.FALSE.equals(Boolean.valueOf(dynRecfg))) {
        ActionReport aReport=context.getActionReport().addSubActionsReport();
        aReport.setActionExitCode(ActionReport.ExitCode.WARNING);
        aReport.setMessage(strings.getLocalString("String_Node_Str","String_Node_Str" + "String_Node_Str",targetName));
        for (        Server s : targetService.getInstances(targetName)) {
          instanceState.setState(s.getName(),InstanceState.StateType.RESTART_REQUIRED,false);
          instanceState.addFailedCommandToInstance(s.getName(),commandName,parameters);
        }
        return ActionReport.ExitCode.WARNING;
      }
    }
    List<Server> instancesForReplication=new ArrayList<Server>();
    if (runtimeTypes.contains(RuntimeType.ALL)) {
      List<Server> allInstances=targetService.getAllInstances();
      Set<String> clusterNoReplication=new HashSet<String>();
      for (      Server s : allInstances) {
        String dynRecfg=s.getConfig().getDynamicReconfigurationEnabled();
        if (Boolean.TRUE.equals(Boolean.valueOf(dynRecfg))) {
          instancesForReplication.add(s);
        }
 else {
          clusterNoReplication.add(s.getCluster().getName());
          instanceState.setState(s.getName(),InstanceState.StateType.RESTART_REQUIRED,false);
          instanceState.addFailedCommandToInstance(s.getName(),commandName,parameters);
        }
      }
      if (!clusterNoReplication.isEmpty()) {
        ActionReport aReport=context.getActionReport().addSubActionsReport();
        aReport.setActionExitCode(ActionReport.ExitCode.WARNING);
        aReport.setMessage(strings.getLocalString("String_Node_Str","String_Node_Str" + "String_Node_Str",clusterNoReplication));
      }
    }
 else {
      instancesForReplication=targetService.getInstances(targetName);
    }
    if (instancesForReplication.isEmpty()) {
      ActionReport aReport=context.getActionReport().addSubActionsReport();
      aReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
      aReport.setMessage(strings.getLocalString("String_Node_Str","String_Node_Str",targetName));
      return ActionReport.ExitCode.SUCCESS;
    }
    return (ClusterOperationUtil.replicateCommand(commandName,clAnnotation.ifFailure(),clAnnotation.ifOffline(),clAnnotation.ifNeverStarted(),instancesForReplication,context,parameters,habitat));
  }
  return ActionReport.ExitCode.SUCCESS;
}

Fixed version (ground truth):
/** 
 * <p>Execute the passed command on targeted remote instances. The list of remote instances is usually retrieved from the passed parameters (with a "target" parameter for instance) or from the configuration. <p>Each remote execution must return a different ActionReport so the user or framework can get feedback on the success or failure or such executions.
 * @param commandName the command to execute
 * @param context the original command context
 * @param parameters the parameters passed to the original local command
 * @return an array of @{link org.glassfish.api.ActionReport} for each remoteexecution status. 
 */
@Override public ActionReport.ExitCode execute(String commandName,AdminCommand command,AdminCommandContext context,ParameterMap parameters){
  CommandModel model=command instanceof CommandModelProvider ? ((CommandModelProvider)command).getModel() : new CommandModelImpl(command.getClass());
  org.glassfish.api.admin.ExecuteOn clAnnotation=model.getClusteringAttributes();
  List<RuntimeType> runtimeTypes=new ArrayList<RuntimeType>();
@ExecuteOn final class DefaultExecuteOn {
  }
  if (clAnnotation == null) {
    clAnnotation=DefaultExecuteOn.class.getAnnotation(ExecuteOn.class);
  }
  if (clAnnotation.value().length == 0) {
    runtimeTypes.add(RuntimeType.DAS);
    runtimeTypes.add(RuntimeType.INSTANCE);
  }
 else {
    runtimeTypes.addAll(Arrays.asList(clAnnotation.value()));
  }
  String targetName=parameters.getOne("String_Node_Str");
  if (targetName == null)   targetName="String_Node_Str";
  if ((runtimeTypes.contains(RuntimeType.ALL)) || ((!CommandTarget.DAS.isValid(habitat,targetName)) && (!CommandTarget.DOMAIN.isValid(habitat,targetName)))) {
    if (targetService.isCluster(targetName) && !runtimeTypes.contains(RuntimeType.ALL)) {
      String dynRecfg=targetService.getClusterConfig(targetName).getDynamicReconfigurationEnabled();
      if (Boolean.FALSE.equals(Boolean.valueOf(dynRecfg))) {
        ActionReport aReport=context.getActionReport().addSubActionsReport();
        aReport.setActionExitCode(ActionReport.ExitCode.WARNING);
        aReport.setMessage(strings.getLocalString("String_Node_Str","String_Node_Str" + "String_Node_Str",targetName));
        for (        Server s : targetService.getInstances(targetName)) {
          instanceState.setState(s.getName(),InstanceState.StateType.RESTART_REQUIRED,false);
          instanceState.addFailedCommandToInstance(s.getName(),commandName,parameters);
        }
        return ActionReport.ExitCode.WARNING;
      }
    }
    List<Server> instancesForReplication=new ArrayList<Server>();
    if (runtimeTypes.contains(RuntimeType.ALL)) {
      List<Server> allInstances=targetService.getAllInstances();
      Set<String> clusterNoReplication=new HashSet<String>();
      for (      Server s : allInstances) {
        String dynRecfg=s.getConfig().getDynamicReconfigurationEnabled();
        if (Boolean.TRUE.equals(Boolean.valueOf(dynRecfg))) {
          instancesForReplication.add(s);
        }
 else {
          clusterNoReplication.add(s.getCluster().getName());
          instanceState.setState(s.getName(),InstanceState.StateType.RESTART_REQUIRED,false);
          instanceState.addFailedCommandToInstance(s.getName(),commandName,parameters);
        }
      }
      if (!clusterNoReplication.isEmpty()) {
        ActionReport aReport=context.getActionReport().addSubActionsReport();
        aReport.setActionExitCode(ActionReport.ExitCode.WARNING);
        aReport.setMessage(strings.getLocalString("String_Node_Str","String_Node_Str" + "String_Node_Str",clusterNoReplication));
      }
    }
 else {
      instancesForReplication=targetService.getInstances(targetName);
    }
    if (instancesForReplication.isEmpty()) {
      ActionReport aReport=context.getActionReport().addSubActionsReport();
      aReport.setActionExitCode(ActionReport.ExitCode.SUCCESS);
      aReport.setMessage(strings.getLocalString("String_Node_Str","String_Node_Str",targetName));
      return ActionReport.ExitCode.SUCCESS;
    }
    return (ClusterOperationUtil.replicateCommand(commandName,clAnnotation.ifFailure(),clAnnotation.ifOffline(),clAnnotation.ifNeverStarted(),instancesForReplication,context,parameters,habitat));
  }
  return ActionReport.ExitCode.SUCCESS;
}