Program: 116750
Project: 116750
Buggy source:
/** 
 * Updates ClusterContext for given cluster
 * @param cluster
 * @return ClusterMonitor - Updated ClusterContext
 * @throws PolicyValidationException
 * @throws PartitionValidationException
 */
public static ClusterMonitor getClusterMonitor(Cluster cluster) throws PolicyValidationException, PartitionValidationException {
  if (null == cluster) {
    return null;
  }
  String autoscalePolicyName=cluster.getAutoscalePolicyName();
  String deploymentPolicyName=cluster.getDeploymentPolicyName();
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + deploymentPolicyName);
    log.debug("String_Node_Str" + autoscalePolicyName);
  }
  AutoscalePolicy policy=PolicyManager.getInstance().getAutoscalePolicy(autoscalePolicyName);
  DeploymentPolicy deploymentPolicy=PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyName);
  if (deploymentPolicy == null) {
    String msg="String_Node_Str" + deploymentPolicyName;
    log.error(msg);
    throw new PolicyValidationException(msg);
  }
  Partition[] allPartitions=deploymentPolicy.getAllPartitions();
  if (allPartitions == null) {
    String msg="String_Node_Str" + deploymentPolicyName;
    log.error(msg);
    throw new PolicyValidationException(msg);
  }
  CloudControllerClient.getInstance().validateDeploymentPolicy(cluster.getServiceName(),deploymentPolicy);
  ClusterMonitor clusterMonitor=new ClusterMonitor(cluster.getClusterId(),cluster.getServiceName(),deploymentPolicy,policy);
  for (  PartitionGroup partitionGroup : deploymentPolicy.getPartitionGroups()) {
    NetworkPartitionContext networkPartitionContext=new NetworkPartitionContext(partitionGroup.getId());
    for (    Partition partition : partitionGroup.getPartitions()) {
      PartitionContext partitionContext=new PartitionContext(partition);
      partitionContext.setServiceName(cluster.getServiceName());
      partitionContext.setProperties(cluster.getProperties());
      partitionContext.setNetworkPartitionId(partitionGroup.getId());
      for (      Member member : cluster.getMembers()) {
        String memberId=member.getMemberId();
        if (member.getPartitionId().equalsIgnoreCase(partition.getId())) {
          MemberContext memberContext=new MemberContext();
          memberContext.setClusterId(member.getClusterId());
          memberContext.setMemberId(memberId);
          memberContext.setPartition(partition);
          if (MemberStatus.Activated.equals(member.getStatus())) {
            partitionContext.addActiveMember(memberContext);
            partitionContext.incrementCurrentActiveMemberCount(1);
          }
 else           if (MemberStatus.Created.equals(member.getStatus()) || MemberStatus.Starting.equals(member.getStatus())) {
            partitionContext.addPendingMember(memberContext);
          }
 else           if (MemberStatus.Suspended.equals(member.getStatus())) {
            partitionContext.addFaultyMember(memberId);
          }
          partitionContext.addMemberStatsContext(new MemberStatsContext(memberId));
          if (log.isInfoEnabled()) {
            log.info(String.format("String_Node_Str",memberId));
          }
        }
      }
      networkPartitionContext.addPartitionContext(partitionContext);
      if (log.isInfoEnabled()) {
        log.info(String.format("String_Node_Str",partitionContext.getPartitionId()));
      }
    }
    clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext);
    if (log.isInfoEnabled()) {
      log.info(String.format("String_Node_Str",networkPartitionContext.getId()));
    }
  }
  java.util.Properties props=cluster.getProperties();
  if (props.containsKey(Constants.LOAD_BALANCER_REF)) {
    String value=props.getProperty(Constants.LOAD_BALANCER_REF);
    clusterMonitor.setLbReferenceType(value);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + value);
    }
  }
  log.info("String_Node_Str" + clusterMonitor.toString());
  return clusterMonitor;
}

Fixed version (ground truth):
/** 
 * Updates ClusterContext for given cluster
 * @param cluster
 * @return ClusterMonitor - Updated ClusterContext
 * @throws PolicyValidationException
 * @throws PartitionValidationException
 */
public static ClusterMonitor getClusterMonitor(Cluster cluster) throws PolicyValidationException, PartitionValidationException {
  if (null == cluster) {
    return null;
  }
  String autoscalePolicyName=cluster.getAutoscalePolicyName();
  String deploymentPolicyName=cluster.getDeploymentPolicyName();
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + deploymentPolicyName);
    log.debug("String_Node_Str" + autoscalePolicyName);
  }
  AutoscalePolicy policy=PolicyManager.getInstance().getAutoscalePolicy(autoscalePolicyName);
  DeploymentPolicy deploymentPolicy=PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyName);
  if (deploymentPolicy == null) {
    String msg="String_Node_Str" + deploymentPolicyName;
    log.error(msg);
    throw new PolicyValidationException(msg);
  }
  Partition[] allPartitions=deploymentPolicy.getAllPartitions();
  if (allPartitions == null) {
    String msg="String_Node_Str" + deploymentPolicyName;
    log.error(msg);
    throw new PolicyValidationException(msg);
  }
  CloudControllerClient.getInstance().validateDeploymentPolicy(cluster.getServiceName(),deploymentPolicy);
  ClusterMonitor clusterMonitor=new ClusterMonitor(cluster.getClusterId(),cluster.getServiceName(),deploymentPolicy,policy);
  for (  PartitionGroup partitionGroup : deploymentPolicy.getPartitionGroups()) {
    NetworkPartitionContext networkPartitionContext=new NetworkPartitionContext(partitionGroup.getId(),partitionGroup.getPartitionAlgo());
    for (    Partition partition : partitionGroup.getPartitions()) {
      PartitionContext partitionContext=new PartitionContext(partition);
      partitionContext.setServiceName(cluster.getServiceName());
      partitionContext.setProperties(cluster.getProperties());
      partitionContext.setNetworkPartitionId(partitionGroup.getId());
      for (      Member member : cluster.getMembers()) {
        String memberId=member.getMemberId();
        if (member.getPartitionId().equalsIgnoreCase(partition.getId())) {
          MemberContext memberContext=new MemberContext();
          memberContext.setClusterId(member.getClusterId());
          memberContext.setMemberId(memberId);
          memberContext.setPartition(partition);
          if (MemberStatus.Activated.equals(member.getStatus())) {
            partitionContext.addActiveMember(memberContext);
            partitionContext.incrementCurrentActiveMemberCount(1);
          }
 else           if (MemberStatus.Created.equals(member.getStatus()) || MemberStatus.Starting.equals(member.getStatus())) {
            partitionContext.addPendingMember(memberContext);
          }
 else           if (MemberStatus.Suspended.equals(member.getStatus())) {
            partitionContext.addFaultyMember(memberId);
          }
          partitionContext.addMemberStatsContext(new MemberStatsContext(memberId));
          if (log.isInfoEnabled()) {
            log.info(String.format("String_Node_Str",memberId));
          }
        }
      }
      networkPartitionContext.addPartitionContext(partitionContext);
      if (log.isInfoEnabled()) {
        log.info(String.format("String_Node_Str",partitionContext.getPartitionId()));
      }
    }
    clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext);
    if (log.isInfoEnabled()) {
      log.info(String.format("String_Node_Str",networkPartitionContext.getId()));
    }
  }
  java.util.Properties props=cluster.getProperties();
  if (props.containsKey(Constants.LOAD_BALANCER_REF)) {
    String value=props.getProperty(Constants.LOAD_BALANCER_REF);
    clusterMonitor.setLbReferenceType(value);
    if (log.isDebugEnabled()) {
      log.debug("String_Node_Str" + value);
    }
  }
  log.info("String_Node_Str" + clusterMonitor.toString());
  return clusterMonitor;
}