Program: 116223
Project: 116223
Buggy source:
private ClusterLevelNetworkPartitionContext parseDeploymentPolicy(ClusterInstance instance,Cluster cluster,DeploymentPolicy deploymentPolicy,ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext) throws PolicyValidationException, PartitionValidationException {
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + deploymentPolicy.getId());
  }
  if (deploymentPolicy == null) {
    String msg="String_Node_Str" + deploymentPolicy.getId();
    log.error(msg);
    throw new PolicyValidationException(msg);
  }
  Partition[] allPartitions=deploymentPolicy.getAllPartitions();
  if (allPartitions == null) {
    String msg="String_Node_Str" + deploymentPolicy.getId();
    log.error(msg);
    throw new PolicyValidationException(msg);
  }
  CloudControllerClient.getInstance().validateDeploymentPolicy(cluster.getServiceName(),deploymentPolicy);
  ChildLevelNetworkPartition networkPartition;
  networkPartition=deploymentPolicy.getChildLevelNetworkPartition(instance.getNetworkPartitionId());
  String networkPartitionId=networkPartition.getId();
  if (clusterLevelNetworkPartitionContext == null) {
    clusterLevelNetworkPartitionContext=new ClusterLevelNetworkPartitionContext(networkPartitionId,networkPartition.getPartitionAlgo(),networkPartition.getMin());
  }
  ClusterInstanceContext clusterInstanceContext=clusterLevelNetworkPartitionContext.getClusterInstanceContext(instance.getInstanceId());
  if (clusterInstanceContext == null) {
    clusterInstanceContext=new ClusterInstanceContext(instance.getInstanceId(),networkPartition.getPartitionAlgo(),networkPartition.getChildLevelPartitions(),networkPartition.getMin());
  }
  for (  ChildLevelPartition partition : networkPartition.getChildLevelPartitions()) {
    ClusterLevelPartitionContext clusterLevelPartitionContext=new ClusterLevelPartitionContext(0);
    clusterLevelPartitionContext.setServiceName(cluster.getServiceName());
    clusterLevelPartitionContext.setProperties(cluster.getProperties());
    clusterLevelPartitionContext.setNetworkPartitionId(networkPartition.getId());
    Partition partition1=deploymentPolicy.getApplicationLevelNetworkPartition(networkPartitionId).getPartition(partition.getPartitionId());
    addMembersFromTopology(cluster,partition1,clusterLevelPartitionContext);
    clusterInstanceContext.addPartitionCtxt(clusterLevelPartitionContext);
    if (log.isInfoEnabled()) {
      log.info(String.format("String_Node_Str",clusterLevelPartitionContext.getPartitionId()));
    }
  }
  if (log.isInfoEnabled()) {
    log.info(String.format("String_Node_Str" + "String_Node_Str",clusterLevelNetworkPartitionContext.getId()));
  }
  return clusterLevelNetworkPartitionContext;
}

Fixed version (ground truth):
private ClusterLevelNetworkPartitionContext parseDeploymentPolicy(ClusterInstance instance,Cluster cluster,ChildPolicy deploymentPolicy,ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext) throws PolicyValidationException, PartitionValidationException {
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + deploymentPolicy.getId());
  }
  if (deploymentPolicy == null) {
    String msg="String_Node_Str" + deploymentPolicy.getId();
    log.error(msg);
    throw new PolicyValidationException(msg);
  }
  ChildLevelPartition[] childLevelPartitions=deploymentPolicy.getChildLevelNetworkPartition(clusterLevelNetworkPartitionContext.getId()).getChildLevelPartitions();
  if (childLevelPartitions == null) {
    String msg="String_Node_Str" + deploymentPolicy.getId();
    log.error(msg);
    throw new PolicyValidationException(msg);
  }
  for (  ChildLevelPartition childLevelPartition : childLevelPartitions) {
    Partition partition=this.deploymentPolicy.getApplicationLevelNetworkPartition(clusterLevelNetworkPartitionContext.getId()).getPartition(childLevelPartition.getPartitionId());
    CloudControllerClient.getInstance().validatePartition(convertTOCCPartition(partition));
  }
  ChildLevelNetworkPartition networkPartition;
  networkPartition=deploymentPolicy.getChildLevelNetworkPartition(instance.getNetworkPartitionId());
  String networkPartitionId=networkPartition.getId();
  if (clusterLevelNetworkPartitionContext == null) {
    clusterLevelNetworkPartitionContext=new ClusterLevelNetworkPartitionContext(networkPartitionId,networkPartition.getPartitionAlgo(),networkPartition.getMin());
  }
  ClusterInstanceContext clusterInstanceContext=clusterLevelNetworkPartitionContext.getClusterInstanceContext(instance.getInstanceId());
  if (clusterInstanceContext == null) {
    clusterInstanceContext=new ClusterInstanceContext(instance.getInstanceId(),networkPartition.getPartitionAlgo(),networkPartition.getChildLevelPartitions(),networkPartition.getMin());
  }
  for (  ChildLevelPartition partition : networkPartition.getChildLevelPartitions()) {
    ClusterLevelPartitionContext clusterLevelPartitionContext=new ClusterLevelPartitionContext(0);
    clusterLevelPartitionContext.setServiceName(cluster.getServiceName());
    clusterLevelPartitionContext.setProperties(cluster.getProperties());
    clusterLevelPartitionContext.setNetworkPartitionId(networkPartition.getId());
    Partition partition1=this.deploymentPolicy.getApplicationLevelNetworkPartition(clusterLevelNetworkPartitionContext.getId()).getPartition(partition.getPartitionId());
    addMembersFromTopology(cluster,partition1,clusterLevelPartitionContext);
    clusterInstanceContext.addPartitionCtxt(clusterLevelPartitionContext);
    if (log.isInfoEnabled()) {
      log.info(String.format("String_Node_Str",clusterLevelPartitionContext.getPartitionId()));
    }
  }
  if (log.isInfoEnabled()) {
    log.info(String.format("String_Node_Str" + "String_Node_Str",clusterLevelNetworkPartitionContext.getId()));
  }
  return clusterLevelNetworkPartitionContext;
}