Program: 116201
Project: 116201
Buggy source:
private ClusterLevelNetworkPartitionContext addPartition(ClusterInstance clusterInstance,Cluster cluster,ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext,ChildLevelPartition childLevelPartition) throws PolicyValidationException, PartitionValidationException {
  if (clusterLevelNetworkPartitionContext == null) {
    String msg="String_Node_Str" + deploymentPolicy.getId();
    log.error(msg);
    throw new PolicyValidationException(msg);
  }
  String nPartitionId=clusterLevelNetworkPartitionContext.getId();
  if (clusterInstance.getPartitionId() == null || childLevelPartition == null) {
    String msg="String_Node_Str" + clusterInstance.getPartitionId() + "String_Node_Str"+ clusterInstance.getNetworkPartitionId()+ "String_Node_Str"+ "String_Node_Str"+ deploymentPolicy.getId();
    log.error(msg);
    throw new PolicyValidationException(msg);
  }
  ClusterInstanceContext clusterInstanceContext=clusterLevelNetworkPartitionContext.getClusterInstanceContext(clusterInstance.getInstanceId());
  int maxInstances=2;
  if (clusterInstanceContext == null) {
    int minInstances=2;
    ApplicationHolder.acquireReadLock();
    try {
      Application application=ApplicationHolder.getApplications().getApplication(cluster.getAppId());
      ClusterDataHolder dataHolder=application.getClusterData(AutoscalerUtil.getAliasFromClusterId(clusterId));
    }
  finally {
      ApplicationHolder.releaseReadLock();
    }
    clusterInstanceContext=new ClusterInstanceContext(clusterInstance.getInstanceId(),clusterLevelNetworkPartitionContext.getPartitionAlgorithm(),minInstances,maxInstances,nPartitionId);
  }
  String partitionId;
  if (childLevelPartition != null) {
    partitionId=childLevelPartition.getPartitionId();
    maxInstances=childLevelPartition.getMax();
  }
 else {
    partitionId=clusterInstance.getPartitionId();
  }
  Partition appPartition=deploymentPolicy.getApplicationLevelNetworkPartition(nPartitionId).getPartition(partitionId);
  org.apache.stratos.cloud.controller.stub.domain.Partition partition=convertTOCCPartition(appPartition);
  CloudControllerClient.getInstance().validatePartition(partition);
  ClusterLevelPartitionContext clusterLevelPartitionContext=new ClusterLevelPartitionContext(maxInstances,partition,clusterInstance.getNetworkPartitionId());
  clusterLevelPartitionContext.setServiceName(cluster.getServiceName());
  clusterLevelPartitionContext.setProperties(cluster.getProperties());
  addMembersFromTopology(cluster,partition,clusterLevelPartitionContext);
  clusterInstanceContext.addPartitionCtxt(clusterLevelPartitionContext);
  clusterLevelNetworkPartitionContext.addClusterInstanceContext(clusterInstanceContext);
  if (log.isInfoEnabled()) {
    log.info(String.format("String_Node_Str",clusterLevelPartitionContext.getPartitionId()));
  }
  return clusterLevelNetworkPartitionContext;
}

Fixed version (ground truth):
private ClusterLevelNetworkPartitionContext addPartition(ClusterInstance clusterInstance,Cluster cluster,ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext,ChildLevelPartition childLevelPartition) throws PolicyValidationException, PartitionValidationException {
  if (clusterLevelNetworkPartitionContext == null) {
    String msg="String_Node_Str" + deploymentPolicy.getId();
    log.error(msg);
    throw new PolicyValidationException(msg);
  }
  String nPartitionId=clusterLevelNetworkPartitionContext.getId();
  if (clusterInstance.getPartitionId() == null && childLevelPartition == null) {
    String msg="String_Node_Str" + clusterInstance.getPartitionId() + "String_Node_Str"+ clusterInstance.getNetworkPartitionId()+ "String_Node_Str"+ "String_Node_Str"+ deploymentPolicy.getId();
    log.error(msg);
    throw new PolicyValidationException(msg);
  }
  ClusterInstanceContext clusterInstanceContext=clusterLevelNetworkPartitionContext.getClusterInstanceContext(clusterInstance.getInstanceId());
  int maxInstances=2;
  if (clusterInstanceContext == null) {
    int minInstances=2;
    ApplicationHolder.acquireReadLock();
    try {
      Application application=ApplicationHolder.getApplications().getApplication(cluster.getAppId());
      ClusterDataHolder dataHolder=application.getClusterData(AutoscalerUtil.getAliasFromClusterId(clusterId));
    }
  finally {
      ApplicationHolder.releaseReadLock();
    }
    clusterInstanceContext=new ClusterInstanceContext(clusterInstance.getInstanceId(),clusterLevelNetworkPartitionContext.getPartitionAlgorithm(),minInstances,maxInstances,nPartitionId);
  }
  String partitionId;
  if (childLevelPartition != null) {
    partitionId=childLevelPartition.getPartitionId();
    maxInstances=childLevelPartition.getMax();
  }
 else {
    partitionId=clusterInstance.getPartitionId();
  }
  Partition appPartition=deploymentPolicy.getApplicationLevelNetworkPartition(nPartitionId).getPartition(partitionId);
  org.apache.stratos.cloud.controller.stub.domain.Partition partition=convertTOCCPartition(appPartition);
  CloudControllerClient.getInstance().validatePartition(partition);
  ClusterLevelPartitionContext clusterLevelPartitionContext=new ClusterLevelPartitionContext(maxInstances,partition,clusterInstance.getNetworkPartitionId());
  clusterLevelPartitionContext.setServiceName(cluster.getServiceName());
  clusterLevelPartitionContext.setProperties(cluster.getProperties());
  addMembersFromTopology(cluster,partition,clusterLevelPartitionContext);
  clusterInstanceContext.addPartitionCtxt(clusterLevelPartitionContext);
  if (log.isInfoEnabled()) {
    log.info(String.format("String_Node_Str",clusterLevelPartitionContext.getPartitionId()));
  }
  clusterLevelNetworkPartitionContext.addClusterInstanceContext(clusterInstanceContext);
  if (log.isInfoEnabled()) {
    log.info(String.format("String_Node_Str" + "String_Node_Str",clusterInstanceContext.getId()));
  }
  return clusterLevelNetworkPartitionContext;
}