Program: 115491
Project: 115491
Buggy source:
/** 
 * Add deployment policy
 * @param deploymentPolicyDefinitionBean DeploymentPolicyBean
 */
public static void addDeploymentPolicy(DeploymentPolicyBean deploymentPolicyDefinitionBean,String deploymentPolicyUuid,int tenantId) throws RestAPIException, AutoscalerServiceDeploymentPolicyAlreadyExistsExceptionException, AutoscalerServiceInvalidDeploymentPolicyExceptionException {
  try {
    if (log.isDebugEnabled()) {
      log.debug(String.format("String_Node_Str" + "String_Node_Str",deploymentPolicyUuid,deploymentPolicyDefinitionBean.getId()));
    }
    NetworkPartitionBean[] networkPartitions=getNetworkPartitions();
    for (    NetworkPartitionReferenceBean networkPartitionReferenceBean : deploymentPolicyDefinitionBean.getNetworkPartitions()) {
      NetworkPartition networkPartition=CloudControllerServiceClient.getInstance().getNetworkPartitionByTenant(networkPartitionReferenceBean.getId(),tenantId);
      for (      NetworkPartitionBean networkPartitionBean : networkPartitions) {
        if (networkPartition.getTenantId() == tenantId && networkPartitionBean.getId().equals(networkPartitionReferenceBean.getId())) {
          networkPartitionReferenceBean.setUuid(networkPartition.getUuid());
          for (          PartitionReferenceBean partition : networkPartitionReferenceBean.getPartitions()) {
            for (            PartitionBean existingPartition : networkPartitionBean.getPartitions()) {
              if (existingPartition.getTenantId() == tenantId && partition.getId().equals(existingPartition.getId())) {
                partition.setUuid(existingPartition.getUuid());
                partition.setTenantId(tenantId);
              }
            }
          }
        }
      }
    }
    AutoscalerServiceClient.getInstance().addDeploymentPolicy(ObjectConverter.convertDeploymentPolicyBeanToASDeploymentPolicy(deploymentPolicyDefinitionBean,deploymentPolicyUuid,tenantId));
    if (log.isDebugEnabled()) {
      log.debug(String.format("String_Node_Str" + "String_Node_Str",deploymentPolicyUuid,deploymentPolicyDefinitionBean.getId()));
    }
  }
 catch (  RemoteException e) {
    String msg=e.getMessage();
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
catch (  AutoscalerServiceRemoteExceptionException e) {
    String msg=e.getMessage();
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
}

Fixed version (ground truth):
/** 
 * Add deployment policy
 * @param deploymentPolicyDefinitionBean DeploymentPolicyBean
 */
public static void addDeploymentPolicy(DeploymentPolicyBean deploymentPolicyDefinitionBean,String deploymentPolicyUuid,int tenantId) throws RestAPIException, AutoscalerServiceDeploymentPolicyAlreadyExistsExceptionException, AutoscalerServiceInvalidDeploymentPolicyExceptionException {
  try {
    if (log.isDebugEnabled()) {
      log.debug(String.format("String_Node_Str" + "String_Node_Str",deploymentPolicyUuid,deploymentPolicyDefinitionBean.getId()));
    }
    NetworkPartitionBean[] networkPartitions=getNetworkPartitions();
    for (    NetworkPartitionReferenceBean networkPartitionReferenceBean : deploymentPolicyDefinitionBean.getNetworkPartitions()) {
      NetworkPartition networkPartition=CloudControllerServiceClient.getInstance().getNetworkPartitionByTenant(networkPartitionReferenceBean.getId(),tenantId);
      if (networkPartition == null) {
        String message=String.format("String_Node_Str" + "String_Node_Str",deploymentPolicyDefinitionBean.getId(),networkPartitionReferenceBean.getId());
        throw new RestAPIException(message);
      }
      for (      NetworkPartitionBean networkPartitionBean : networkPartitions) {
        if (networkPartition.getTenantId() == tenantId && networkPartitionBean.getId().equals(networkPartitionReferenceBean.getId())) {
          networkPartitionReferenceBean.setUuid(networkPartition.getUuid());
          for (          PartitionReferenceBean partition : networkPartitionReferenceBean.getPartitions()) {
            for (            PartitionBean existingPartition : networkPartitionBean.getPartitions()) {
              if (existingPartition.getTenantId() == tenantId && partition.getId().equals(existingPartition.getId())) {
                partition.setUuid(existingPartition.getUuid());
                partition.setTenantId(tenantId);
              }
            }
          }
        }
      }
    }
    AutoscalerServiceClient.getInstance().addDeploymentPolicy(ObjectConverter.convertDeploymentPolicyBeanToASDeploymentPolicy(deploymentPolicyDefinitionBean,deploymentPolicyUuid,tenantId));
    if (log.isDebugEnabled()) {
      log.debug(String.format("String_Node_Str" + "String_Node_Str",deploymentPolicyUuid,deploymentPolicyDefinitionBean.getId()));
    }
  }
 catch (  RemoteException e) {
    String msg=e.getMessage();
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
catch (  AutoscalerServiceRemoteExceptionException e) {
    String msg=e.getMessage();
    log.error(msg,e);
    throw new RestAPIException(msg,e);
  }
}