Program: 115933
Project: 115933
Buggy source:
/** 
 * Gets the group level network partition context.
 * @param parentInstanceContext the parent instance context
 * @return the group level network partition context
 */
private GroupLevelNetworkPartitionContext getGroupLevelNetworkPartitionContext(String groupAlias,String appId,Instance parentInstanceContext){
  GroupLevelNetworkPartitionContext groupLevelNetworkPartitionContext;
  String deploymentPolicyId=AutoscalerUtil.getDeploymentPolicyIdByAlias(appId,groupAlias);
  DeploymentPolicy deploymentPolicy=null;
  try {
    deploymentPolicy=CloudControllerServiceClient.getInstance().getDeploymentPolicy(deploymentPolicyId);
  }
 catch (  Exception e) {
    String msg=String.format("String_Node_Str",deploymentPolicyId,e);
    log.error(msg,e);
    return null;
  }
  String networkPartitionId=parentInstanceContext.getNetworkPartitionId();
  if (this.networkPartitionCtxts.containsKey(networkPartitionId)) {
    groupLevelNetworkPartitionContext=(GroupLevelNetworkPartitionContext)this.networkPartitionCtxts.get(networkPartitionId);
  }
 else {
    if (deploymentPolicy != null) {
      NetworkPartitionRef[] networkPartitionRefs=deploymentPolicy.getNetworkPartitionsRef();
      NetworkPartitionRef networkPartitionRef=null;
      for (int i=0; i < networkPartitionRefs.length; i++) {
        if (networkPartitionRefs[i].getId().equals(networkPartitionId)) {
          networkPartitionRef=networkPartitionRefs[i];
        }
      }
      if (networkPartitionRef != null) {
        groupLevelNetworkPartitionContext=new GroupLevelNetworkPartitionContext(networkPartitionId,networkPartitionRef.getPartitionAlgo());
      }
 else {
        groupLevelNetworkPartitionContext=new GroupLevelNetworkPartitionContext(networkPartitionId);
      }
    }
 else {
      groupLevelNetworkPartitionContext=new GroupLevelNetworkPartitionContext(networkPartitionId);
    }
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + networkPartitionId + "String_Node_Str"+ "String_Node_Str"+ this.id);
    }
    this.addNetworkPartitionContext(groupLevelNetworkPartitionContext);
  }
  return groupLevelNetworkPartitionContext;
}

Fixed version (ground truth):
/** 
 * Gets the group level network partition context.
 * @param parentInstanceContext the parent instance context
 * @return the group level network partition context
 */
private GroupLevelNetworkPartitionContext getGroupLevelNetworkPartitionContext(String groupAlias,String appId,Instance parentInstanceContext){
  GroupLevelNetworkPartitionContext groupLevelNetworkPartitionContext;
  String deploymentPolicyId=AutoscalerUtil.getDeploymentPolicyIdByAlias(appId,groupAlias);
  DeploymentPolicy deploymentPolicy=null;
  try {
    deploymentPolicy=CloudControllerServiceClient.getInstance().getDeploymentPolicy(deploymentPolicyId);
  }
 catch (  CloudControllerServiceDeploymentPolicyNotExistsExceptionException e) {
    String msg=String.format("String_Node_Str",deploymentPolicyId);
    log.warn(msg);
  }
catch (  Exception e) {
    String msg=String.format("String_Node_Str",deploymentPolicyId,e);
    log.error(msg,e);
    throw new org.apache.stratos.autoscaler.exception.AutoScalerException(msg,e);
  }
  String networkPartitionId=parentInstanceContext.getNetworkPartitionId();
  if (this.networkPartitionCtxts.containsKey(networkPartitionId)) {
    groupLevelNetworkPartitionContext=(GroupLevelNetworkPartitionContext)this.networkPartitionCtxts.get(networkPartitionId);
  }
 else {
    if (deploymentPolicy != null) {
      NetworkPartitionRef[] networkPartitionRefs=deploymentPolicy.getNetworkPartitionsRef();
      NetworkPartitionRef networkPartitionRef=null;
      for (int i=0; i < networkPartitionRefs.length; i++) {
        if (networkPartitionRefs[i].getId().equals(networkPartitionId)) {
          networkPartitionRef=networkPartitionRefs[i];
        }
      }
      if (networkPartitionRef != null) {
        groupLevelNetworkPartitionContext=new GroupLevelNetworkPartitionContext(networkPartitionId,networkPartitionRef.getPartitionAlgo());
      }
 else {
        groupLevelNetworkPartitionContext=new GroupLevelNetworkPartitionContext(networkPartitionId);
      }
    }
 else {
      groupLevelNetworkPartitionContext=new GroupLevelNetworkPartitionContext(networkPartitionId);
    }
    if (log.isInfoEnabled()) {
      log.info("String_Node_Str" + networkPartitionId + "String_Node_Str"+ "String_Node_Str"+ this.id);
    }
    this.addNetworkPartitionContext(groupLevelNetworkPartitionContext);
  }
  return groupLevelNetworkPartitionContext;
}