Program: 28569
Project: 28569
Buggy source:
public void execute(AdminCommandContext context){
  report=context.getActionReport();
  report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
  Logger logger=context.getLogger();
  ActionReport.MessagePart top=report.getTopMessagePart();
  List<Cluster> clusterList=null;
  if (whichTarget.equals("String_Node_Str")) {
    Clusters clusters=domain.getClusters();
    clusterList=clusters.getCluster();
  }
 else {
    clusterList=createClusterList();
    if (clusterList == null) {
      fail(Strings.get("String_Node_Str",whichTarget));
      return;
    }
  }
  StringBuilder sb=new StringBuilder();
  if (clusterList.size() < 1) {
    sb.append(NONE);
  }
  int timeoutInMsec=2000;
  Map<String,ClusterInfo> clusterMap=new HashMap<String,ClusterInfo>();
  List<InstanceInfo> infos=new LinkedList<InstanceInfo>();
  for (  Cluster cluster : clusterList) {
    String clusterName=cluster.getName();
    List<Server> servers=cluster.getInstances();
    if (servers.isEmpty()) {
      ClusterInfo ci=clusterMap.get(clusterName);
      if (ci == null) {
        ci=new ClusterInfo(clusterName);
      }
      ci.serversEmpty=true;
      clusterMap.put(clusterName,ci);
    }
    for (    Server server : servers) {
      String name=server.getName();
      if (name != null) {
        ActionReport tReport=habitat.getService(ActionReport.class,"String_Node_Str");
        InstanceInfo ii=new InstanceInfo(habitat,server,helper.getAdminPort(server),server.getAdminHost(),clusterName,logger,timeoutInMsec,tReport,stateService);
        infos.add(ii);
      }
    }
  }
  for (  InstanceInfo ii : infos) {
    String clusterforInstance=ii.getCluster();
    ClusterInfo ci=clusterMap.get(clusterforInstance);
    if (ci == null) {
      ci=new ClusterInfo(clusterforInstance);
    }
    ci.allInstancesRunning&=ii.isRunning();
    if (ii.isRunning()) {
      ci.atleastOneInstanceRunning=true;
    }
    clusterMap.put(clusterforInstance,ci);
  }
  String display;
  String value;
  for (  ClusterInfo ci : clusterMap.values()) {
    if (ci.serversEmpty || !ci.atleastOneInstanceRunning) {
      display=InstanceState.StateType.NOT_RUNNING.getDisplayString();
      value=InstanceState.StateType.NOT_RUNNING.getDescription();
    }
 else     if (ci.allInstancesRunning) {
      display=InstanceState.StateType.RUNNING.getDisplayString();
      value=InstanceState.StateType.RUNNING.getDescription();
    }
 else {
      display=PARTIALLY_RUNNING_DISPLAY;
      value=PARTIALLY_RUNNING;
    }
    sb.append(ci.getName()).append(display).append(EOL);
    top.addProperty(ci.getName(),value);
  }
  String output=sb.toString();
  report.setMessage(output.substring(0,output.length() - 1));
}

Fixed version (ground truth):
public void execute(AdminCommandContext context){
  ActionReport report=context.getActionReport();
  report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
  Logger logger=context.getLogger();
  ActionReport.MessagePart top=report.getTopMessagePart();
  List<Cluster> clusterList=null;
  if (whichTarget.equals("String_Node_Str")) {
    Clusters clusters=domain.getClusters();
    clusterList=clusters.getCluster();
  }
 else {
    clusterList=createClusterList();
    if (clusterList == null) {
      report.setActionExitCode(ActionReport.ExitCode.FAILURE);
      report.setMessage(Strings.get("String_Node_Str",whichTarget));
      return;
    }
  }
  StringBuilder sb=new StringBuilder();
  if (clusterList.size() < 1) {
    sb.append(NONE);
  }
  int timeoutInMsec=2000;
  Map<String,ClusterInfo> clusterMap=new HashMap<String,ClusterInfo>();
  List<InstanceInfo> infos=new LinkedList<InstanceInfo>();
  for (  Cluster cluster : clusterList) {
    String clusterName=cluster.getName();
    List<Server> servers=cluster.getInstances();
    if (servers.isEmpty()) {
      ClusterInfo ci=clusterMap.get(clusterName);
      if (ci == null) {
        ci=new ClusterInfo(clusterName);
      }
      ci.serversEmpty=true;
      clusterMap.put(clusterName,ci);
    }
    for (    Server server : servers) {
      String name=server.getName();
      if (name != null) {
        ActionReport tReport=habitat.getService(ActionReport.class,"String_Node_Str");
        InstanceInfo ii=new InstanceInfo(habitat,server,new RemoteInstanceCommandHelper(habitat).getAdminPort(server),server.getAdminHost(),clusterName,logger,timeoutInMsec,tReport,stateService);
        infos.add(ii);
      }
    }
  }
  for (  InstanceInfo ii : infos) {
    String clusterforInstance=ii.getCluster();
    ClusterInfo ci=clusterMap.get(clusterforInstance);
    if (ci == null) {
      ci=new ClusterInfo(clusterforInstance);
    }
    ci.allInstancesRunning&=ii.isRunning();
    if (ii.isRunning()) {
      ci.atleastOneInstanceRunning=true;
    }
    clusterMap.put(clusterforInstance,ci);
  }
  String display;
  String value;
  for (  ClusterInfo ci : clusterMap.values()) {
    if (ci.serversEmpty || !ci.atleastOneInstanceRunning) {
      display=InstanceState.StateType.NOT_RUNNING.getDisplayString();
      value=InstanceState.StateType.NOT_RUNNING.getDescription();
    }
 else     if (ci.allInstancesRunning) {
      display=InstanceState.StateType.RUNNING.getDisplayString();
      value=InstanceState.StateType.RUNNING.getDescription();
    }
 else {
      display=PARTIALLY_RUNNING_DISPLAY;
      value=PARTIALLY_RUNNING;
    }
    sb.append(ci.getName()).append(display).append(EOL);
    top.addProperty(ci.getName(),value);
  }
  String output=sb.toString();
  report.setMessage(output.substring(0,output.length() - 1));
}