Program: 107480
Project: 107480
Buggy source:
@Override public List<Pair<String,Object>> execute(Map<String,Object> params){
  Account account=(Account)params.get(BaseCmd.Properties.ACCOUNT_OBJ.getName());
  Long userId=(Long)params.get(BaseCmd.Properties.USER_ID.getName());
  String accountName=(String)params.get(BaseCmd.Properties.ACCOUNT.getName());
  Long domainId=(Long)params.get(BaseCmd.Properties.DOMAIN_ID.getName());
  String name=(String)params.get(BaseCmd.Properties.NAME.getName());
  Long zoneId=(Long)params.get(BaseCmd.Properties.ZONE_ID.getName());
  Long diskOfferingId=(Long)params.get(BaseCmd.Properties.DISK_OFFERING_ID.getName());
  Long snapshotId=(Long)params.get(BaseCmd.Properties.SNAPSHOT_ID.getName());
  Long size=(Long)params.get(BaseCmd.Properties.SIZE.getName());
  if (account == null) {
    if ((accountName == null) || (domainId == null)) {
      throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str");
    }
    account=getManagementServer().findActiveAccount(accountName,domainId);
    if (account == null)     throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + accountName + "String_Node_Str"+ domainId);
  }
 else {
    if (isAdmin(account.getType())) {
      if (domainId != null) {
        if (!getManagementServer().isChildDomain(account.getDomainId(),domainId)) {
          throw new ServerApiException(BaseCmd.ACCOUNT_ERROR,"String_Node_Str" + domainId + "String_Node_Str");
        }
        if (accountName != null) {
          account=getManagementServer().findActiveAccount(accountName,domainId);
          if (account == null)           throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + accountName + "String_Node_Str"+ domainId);
        }
      }
    }
  }
  if (userId == null) {
    userId=Long.valueOf(Account.ACCOUNT_ID_SYSTEM);
  }
  if (size == null) {
    size=Long.valueOf(0);
  }
  boolean useSnapshot=false;
  if (snapshotId == null) {
    if ((zoneId == null)) {
      throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str");
    }
    if (diskOfferingId == null && size == 0) {
      throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str");
    }
 else     if (diskOfferingId == null && size != 0) {
      try {
        boolean ok=getManagementServer().validateCustomVolumeSizeRange(size);
        if (!ok)         throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str");
      }
 catch (      InvalidParameterValueException e) {
        s_logger.warn("String_Node_Str");
        throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + e.getMessage());
      }
      List<DiskOfferingVO> privateTemplateList=getManagementServer().findPrivateDiskOffering();
      diskOfferingId=privateTemplateList.get(0).getId();
    }
  }
 else {
    useSnapshot=true;
    Snapshot snapshotCheck=getManagementServer().findSnapshotById(snapshotId);
    if (snapshotCheck == null) {
      throw new ServerApiException(BaseCmd.SNAPSHOT_INVALID_PARAM_ERROR,"String_Node_Str" + snapshotId);
    }
    if (account != null) {
      if (isAdmin(account.getType())) {
        Account snapshotOwner=getManagementServer().findAccountById(snapshotCheck.getAccountId());
        if (!getManagementServer().isChildDomain(account.getDomainId(),snapshotOwner.getDomainId())) {
          throw new ServerApiException(BaseCmd.ACCOUNT_ERROR,"String_Node_Str" + snapshotId + "String_Node_Str");
        }
      }
 else       if (account.getId() != snapshotCheck.getAccountId()) {
        throw new ServerApiException(BaseCmd.SNAPSHOT_INVALID_PARAM_ERROR,"String_Node_Str" + snapshotId + "String_Node_Str");
      }
    }
  }
  try {
    long jobId=0;
    if (useSnapshot) {
      jobId=getManagementServer().createVolumeFromSnapshotAsync(userId,account.getId(),snapshotId,name);
    }
 else {
      jobId=getManagementServer().createVolumeAsync(userId,account.getId(),name,zoneId,diskOfferingId,size);
    }
    if (jobId == 0) {
      s_logger.warn("String_Node_Str");
    }
 else {
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str" + jobId);
    }
    long volumeId=waitInstanceCreation(jobId);
    List<Pair<String,Object>> returnValues=new ArrayList<Pair<String,Object>>();
    returnValues.add(new Pair<String,Object>(BaseCmd.Properties.JOB_ID.getName(),Long.valueOf(jobId)));
    returnValues.add(new Pair<String,Object>(BaseCmd.Properties.VOLUME_ID.getName(),Long.valueOf(volumeId)));
    return returnValues;
  }
 catch (  Exception ex) {
    s_logger.error("String_Node_Str" + (useSnapshot ? ("String_Node_Str" + snapshotId) : ("String_Node_Str" + zoneId + "String_Node_Str"+ diskOfferingId)),ex);
    if (useSnapshot) {
      throw new ServerApiException(BaseCmd.CREATE_VOLUME_FROM_SNAPSHOT_ERROR,"String_Node_Str" + snapshotId + "String_Node_Str");
    }
 else {
      throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str" + ex.getMessage());
    }
  }
}

Fixed version (ground truth):
@Override public List<Pair<String,Object>> execute(Map<String,Object> params){
  Account account=(Account)params.get(BaseCmd.Properties.ACCOUNT_OBJ.getName());
  Long userId=(Long)params.get(BaseCmd.Properties.USER_ID.getName());
  String accountName=(String)params.get(BaseCmd.Properties.ACCOUNT.getName());
  Long domainId=(Long)params.get(BaseCmd.Properties.DOMAIN_ID.getName());
  String name=(String)params.get(BaseCmd.Properties.NAME.getName());
  Long zoneId=(Long)params.get(BaseCmd.Properties.ZONE_ID.getName());
  Long diskOfferingId=(Long)params.get(BaseCmd.Properties.DISK_OFFERING_ID.getName());
  Long snapshotId=(Long)params.get(BaseCmd.Properties.SNAPSHOT_ID.getName());
  Long size=(Long)params.get(BaseCmd.Properties.SIZE.getName());
  if (account == null) {
    if ((accountName == null) || (domainId == null)) {
      throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str");
    }
    account=getManagementServer().findActiveAccount(accountName,domainId);
    if (account == null)     throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + accountName + "String_Node_Str"+ domainId);
  }
 else {
    if (isAdmin(account.getType())) {
      if (domainId != null) {
        if (!getManagementServer().isChildDomain(account.getDomainId(),domainId)) {
          throw new ServerApiException(BaseCmd.ACCOUNT_ERROR,"String_Node_Str" + domainId + "String_Node_Str");
        }
        if (accountName != null) {
          account=getManagementServer().findActiveAccount(accountName,domainId);
          if (account == null)           throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + accountName + "String_Node_Str"+ domainId);
        }
      }
    }
  }
  if (userId == null) {
    userId=Long.valueOf(Account.ACCOUNT_ID_SYSTEM);
  }
  if (size == null) {
    size=Long.valueOf(0);
  }
  if (diskOfferingId != null) {
    DiskOfferingVO dOffering=getManagementServer().findDiskOfferingById(diskOfferingId.longValue());
    if (dOffering == null) {
      throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + diskOfferingId + "String_Node_Str");
    }
  }
  boolean useSnapshot=false;
  if (snapshotId == null) {
    if ((zoneId == null)) {
      throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str");
    }
    if (diskOfferingId == null && size == 0) {
      throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str");
    }
 else     if (diskOfferingId == null && size != 0) {
      try {
        boolean ok=getManagementServer().validateCustomVolumeSizeRange(size);
        if (!ok)         throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str");
      }
 catch (      InvalidParameterValueException e) {
        s_logger.warn("String_Node_Str");
        throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + e.getMessage());
      }
      List<DiskOfferingVO> privateTemplateList=getManagementServer().findPrivateDiskOffering();
      diskOfferingId=privateTemplateList.get(0).getId();
    }
  }
 else {
    useSnapshot=true;
    Snapshot snapshotCheck=getManagementServer().findSnapshotById(snapshotId);
    if (snapshotCheck == null) {
      throw new ServerApiException(BaseCmd.SNAPSHOT_INVALID_PARAM_ERROR,"String_Node_Str" + snapshotId);
    }
    if (account != null) {
      if (isAdmin(account.getType())) {
        Account snapshotOwner=getManagementServer().findAccountById(snapshotCheck.getAccountId());
        if (!getManagementServer().isChildDomain(account.getDomainId(),snapshotOwner.getDomainId())) {
          throw new ServerApiException(BaseCmd.ACCOUNT_ERROR,"String_Node_Str" + snapshotId + "String_Node_Str");
        }
      }
 else       if (account.getId() != snapshotCheck.getAccountId()) {
        throw new ServerApiException(BaseCmd.SNAPSHOT_INVALID_PARAM_ERROR,"String_Node_Str" + snapshotId + "String_Node_Str");
      }
    }
  }
  try {
    long jobId=0;
    if (useSnapshot) {
      jobId=getManagementServer().createVolumeFromSnapshotAsync(userId,account.getId(),snapshotId,name);
    }
 else {
      jobId=getManagementServer().createVolumeAsync(userId,account.getId(),name,zoneId,diskOfferingId,size);
    }
    if (jobId == 0) {
      s_logger.warn("String_Node_Str");
    }
 else {
      if (s_logger.isDebugEnabled())       s_logger.debug("String_Node_Str" + jobId);
    }
    long volumeId=waitInstanceCreation(jobId);
    List<Pair<String,Object>> returnValues=new ArrayList<Pair<String,Object>>();
    returnValues.add(new Pair<String,Object>(BaseCmd.Properties.JOB_ID.getName(),Long.valueOf(jobId)));
    returnValues.add(new Pair<String,Object>(BaseCmd.Properties.VOLUME_ID.getName(),Long.valueOf(volumeId)));
    return returnValues;
  }
 catch (  Exception ex) {
    s_logger.error("String_Node_Str" + (useSnapshot ? ("String_Node_Str" + snapshotId) : ("String_Node_Str" + zoneId + "String_Node_Str"+ diskOfferingId)),ex);
    if (useSnapshot) {
      throw new ServerApiException(BaseCmd.CREATE_VOLUME_FROM_SNAPSHOT_ERROR,"String_Node_Str" + snapshotId + "String_Node_Str");
    }
 else {
      throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str" + ex.getMessage());
    }
  }
}