Program: 116185
Project: 116185
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=1;
  if (clusterInstanceContext == null) {
    int minInstances=1;
    ApplicationHolder.acquireReadLock();
    try {
      Application application=ApplicationHolder.getApplications().getApplication(cluster.getAppId());
      ClusterDataHolder dataHolder=application.getClusterData(AutoscalerUtil.getAliasFromClusterId(clusterId));
      minInstances=dataHolder.getMinInstances();
      maxInstances=dataHolder.getMaxInstances();
    }
  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);
  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;
}

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=1;
  if (clusterInstanceContext == null) {
    int minInstances=1;
    ApplicationHolder.acquireReadLock();
    try {
      Application application=ApplicationHolder.getApplications().getApplication(cluster.getAppId());
      ClusterDataHolder dataHolder=application.getClusterDataHolderRecursivelyByAlias(AutoscalerUtil.getAliasFromClusterId(clusterId));
      minInstances=dataHolder.getMinInstances();
      maxInstances=dataHolder.getMaxInstances();
    }
  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);
  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;
}