Program: 107488
Project: 107488
Buggy source:
@Override public List<Pair<String,Object>> execute(Map<String,Object> params){
  Account account=(Account)params.get(BaseCmd.Properties.ACCOUNT_OBJ.getName());
  Long id=(Long)params.get(BaseCmd.Properties.ID.getName());
  String type=(String)params.get(BaseCmd.Properties.TYPE.getName());
  String name=(String)params.get(BaseCmd.Properties.NAME.getName());
  Long zoneId=(Long)params.get(BaseCmd.Properties.ZONE_ID.getName());
  Long podId=(Long)params.get(BaseCmd.Properties.POD_ID.getName());
  Long vmId=(Long)params.get(BaseCmd.Properties.VIRTUAL_MACHINE_ID.getName());
  String accountName=(String)params.get(BaseCmd.Properties.ACCOUNT.getName());
  Long domainId=(Long)params.get(BaseCmd.Properties.DOMAIN_ID.getName());
  Long hostId=(Long)params.get(BaseCmd.Properties.HOST_ID.getName());
  String keyword=(String)params.get(BaseCmd.Properties.KEYWORD.getName());
  Integer page=(Integer)params.get(BaseCmd.Properties.PAGE.getName());
  Integer pageSize=(Integer)params.get(BaseCmd.Properties.PAGESIZE.getName());
  Long accountId=null;
  boolean isAdmin=false;
  if ((account == null) || isAdmin(account.getType())) {
    isAdmin=true;
    if (domainId != null) {
      if ((account != null) && !getManagementServer().isChildDomain(account.getDomainId(),domainId)) {
        throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + domainId + "String_Node_Str");
      }
      if (accountName != null) {
        Account userAccount=getManagementServer().findActiveAccount(accountName,domainId);
        if (userAccount != null) {
          accountId=userAccount.getId();
        }
 else {
          throw new ServerApiException(BaseCmd.ACCOUNT_ERROR,"String_Node_Str" + accountName + "String_Node_Str"+ domainId);
        }
      }
    }
 else {
      domainId=((account == null) ? DomainVO.ROOT_DOMAIN : account.getDomainId());
    }
  }
 else {
    accountId=account.getId();
  }
  Long[] accountIds=null;
  if (accountId != null) {
    accountIds=new Long[1];
    accountIds[0]=accountId;
  }
  Long startIndex=Long.valueOf(0);
  int pageSizeNum=50;
  if (pageSize != null) {
    pageSizeNum=pageSize.intValue();
  }
  if (page != null) {
    int pageNum=page.intValue();
    if (pageNum > 0) {
      startIndex=Long.valueOf(pageSizeNum * (pageNum - 1));
    }
  }
  Criteria c=new Criteria("String_Node_Str",Boolean.FALSE,startIndex,Long.valueOf(pageSizeNum));
  c.addCriteria(Criteria.ACCOUNTID,accountIds);
  if (keyword != null) {
    c.addCriteria(Criteria.KEYWORD,keyword);
  }
 else {
    c.addCriteria(Criteria.ID,id);
    c.addCriteria(Criteria.INSTANCEID,vmId);
    c.addCriteria(Criteria.NAME,name);
    if (isAdmin) {
      c.addCriteria(Criteria.VTYPE,type);
      c.addCriteria(Criteria.DATACENTERID,zoneId);
      c.addCriteria(Criteria.PODID,podId);
      c.addCriteria(Criteria.HOSTID,hostId);
      c.addCriteria(Criteria.DOMAINID,domainId);
    }
  }
  List<VolumeVO> volumes=getManagementServer().searchForVolumes(c);
  if (volumes == null || volumes.size() == 0) {
    throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str");
  }
  List<Pair<String,Object>> volumeTags=new ArrayList<Pair<String,Object>>();
  Object[] vTag=new Object[volumes.size()];
  int i=0;
  for (  VolumeVO volume : volumes) {
    List<Pair<String,Object>> volumeData=new ArrayList<Pair<String,Object>>();
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.ID.getName(),volume.getId()));
    AsyncJobVO asyncJob=getManagementServer().findInstancePendingAsyncJob("String_Node_Str",volume.getId());
    if (asyncJob != null) {
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.JOB_ID.getName(),asyncJob.getId().toString()));
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.JOB_STATUS.getName(),String.valueOf(asyncJob.getStatus())));
    }
    if (volume.getName() != null) {
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.NAME.getName(),volume.getName()));
    }
 else {
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.NAME.getName(),"String_Node_Str"));
    }
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.ZONE_ID.getName(),Long.valueOf(volume.getDataCenterId()).toString()));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.ZONE_NAME.getName(),getManagementServer().findDataCenterById(volume.getDataCenterId()).getName()));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.TYPE.getName(),volume.getVolumeType()));
    if (volume.getDeviceId() != null)     volumeData.add(new Pair<String,Object>(BaseCmd.Properties.DEVICE_ID.getName(),Long.valueOf(volume.getDeviceId()).toString()));
    Long instanceId=volume.getInstanceId();
    if (instanceId != null) {
      VMInstanceVO vm=getManagementServer().findVMInstanceById(instanceId);
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.VIRTUAL_MACHINE_ID.getName(),vm.getId()));
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.VIRTUAL_MACHINE_NAME.getName(),vm.getName()));
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.VIRTUAL_MACHINE_DISPLAYNAME.getName(),vm.getName()));
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.VIRTUAL_MACHINE_STATE.getName(),vm.getState()));
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.DEVICE_ID.getName(),volume.getDeviceId()));
    }
    long virtualSizeInBytes=volume.getSize();
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.SIZE.getName(),virtualSizeInBytes));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.CREATED.getName(),getDateString(volume.getCreated())));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.ATTACHED.getName(),getDateString(volume.getAttached())));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.STATE.getName(),volume.getStatus()));
    Account accountTemp=getManagementServer().findAccountById(volume.getAccountId());
    if (accountTemp != null) {
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.ACCOUNT.getName(),accountTemp.getAccountName()));
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.DOMAIN_ID.getName(),accountTemp.getDomainId()));
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.DOMAIN.getName(),getManagementServer().findDomainIdById(accountTemp.getDomainId()).getName()));
    }
    String storageType;
    try {
      if (volume.getPoolId() == null) {
        storageType="String_Node_Str";
      }
 else {
        storageType=getManagementServer().volumeIsOnSharedStorage(volume.getId()) ? "String_Node_Str" : "String_Node_Str";
      }
    }
 catch (    InvalidParameterValueException e) {
      s_logger.error(e.getMessage(),e);
      throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str" + volume.getName() + "String_Node_Str");
    }
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.STORAGE_TYPE.getName(),storageType));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.DISK_OFFERING_ID.getName(),volume.getDiskOfferingId()));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.DISK_OFFERING_NAME.getName(),getManagementServer().findDiskOfferingById(volume.getDiskOfferingId()).getName()));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.DISK_OFFERING_DISPLAY_TEXT.getName(),getManagementServer().findDiskOfferingById(volume.getDiskOfferingId()).getDisplayText()));
    Long poolId=volume.getPoolId();
    String poolName=(poolId == null) ? "String_Node_Str" : getManagementServer().findPoolById(poolId).getName();
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.STORAGE.getName(),poolName));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.SOURCE_ID.getName(),volume.getSourceId()));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.SOURCE_TYPE.getName(),volume.getSourceType().toString()));
    vTag[i++]=volumeData;
  }
  Pair<String,Object> volumeTag=new Pair<String,Object>("String_Node_Str",vTag);
  volumeTags.add(volumeTag);
  return volumeTags;
}

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 id=(Long)params.get(BaseCmd.Properties.ID.getName());
  String type=(String)params.get(BaseCmd.Properties.TYPE.getName());
  String name=(String)params.get(BaseCmd.Properties.NAME.getName());
  Long zoneId=(Long)params.get(BaseCmd.Properties.ZONE_ID.getName());
  Long podId=(Long)params.get(BaseCmd.Properties.POD_ID.getName());
  Long vmId=(Long)params.get(BaseCmd.Properties.VIRTUAL_MACHINE_ID.getName());
  String accountName=(String)params.get(BaseCmd.Properties.ACCOUNT.getName());
  Long domainId=(Long)params.get(BaseCmd.Properties.DOMAIN_ID.getName());
  Long hostId=(Long)params.get(BaseCmd.Properties.HOST_ID.getName());
  String keyword=(String)params.get(BaseCmd.Properties.KEYWORD.getName());
  Integer page=(Integer)params.get(BaseCmd.Properties.PAGE.getName());
  Integer pageSize=(Integer)params.get(BaseCmd.Properties.PAGESIZE.getName());
  Long accountId=null;
  boolean isAdmin=false;
  if ((account == null) || isAdmin(account.getType())) {
    isAdmin=true;
    if (domainId != null) {
      if ((account != null) && !getManagementServer().isChildDomain(account.getDomainId(),domainId)) {
        throw new ServerApiException(BaseCmd.PARAM_ERROR,"String_Node_Str" + domainId + "String_Node_Str");
      }
      if (accountName != null) {
        Account userAccount=getManagementServer().findActiveAccount(accountName,domainId);
        if (userAccount != null) {
          accountId=userAccount.getId();
        }
 else {
          throw new ServerApiException(BaseCmd.ACCOUNT_ERROR,"String_Node_Str" + accountName + "String_Node_Str"+ domainId);
        }
      }
    }
 else {
      domainId=((account == null) ? DomainVO.ROOT_DOMAIN : account.getDomainId());
    }
  }
 else {
    accountId=account.getId();
  }
  Long[] accountIds=null;
  if (accountId != null) {
    accountIds=new Long[1];
    accountIds[0]=accountId;
  }
  Long startIndex=Long.valueOf(0);
  int pageSizeNum=50;
  if (pageSize != null) {
    pageSizeNum=pageSize.intValue();
  }
  if (page != null) {
    int pageNum=page.intValue();
    if (pageNum > 0) {
      startIndex=Long.valueOf(pageSizeNum * (pageNum - 1));
    }
  }
  Criteria c=new Criteria("String_Node_Str",Boolean.FALSE,startIndex,Long.valueOf(pageSizeNum));
  c.addCriteria(Criteria.ACCOUNTID,accountIds);
  if (keyword != null) {
    c.addCriteria(Criteria.KEYWORD,keyword);
  }
 else {
    c.addCriteria(Criteria.ID,id);
    c.addCriteria(Criteria.INSTANCEID,vmId);
    c.addCriteria(Criteria.NAME,name);
    if (isAdmin) {
      c.addCriteria(Criteria.VTYPE,type);
      c.addCriteria(Criteria.DATACENTERID,zoneId);
      c.addCriteria(Criteria.PODID,podId);
      c.addCriteria(Criteria.HOSTID,hostId);
      c.addCriteria(Criteria.DOMAINID,domainId);
    }
  }
  List<VolumeVO> volumes=getManagementServer().searchForVolumes(c);
  if (volumes == null) {
    throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str");
  }
  List<Pair<String,Object>> volumeTags=new ArrayList<Pair<String,Object>>();
  Object[] vTag=new Object[volumes.size()];
  int i=0;
  for (  VolumeVO volume : volumes) {
    List<Pair<String,Object>> volumeData=new ArrayList<Pair<String,Object>>();
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.ID.getName(),volume.getId()));
    AsyncJobVO asyncJob=getManagementServer().findInstancePendingAsyncJob("String_Node_Str",volume.getId());
    if (asyncJob != null) {
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.JOB_ID.getName(),asyncJob.getId().toString()));
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.JOB_STATUS.getName(),String.valueOf(asyncJob.getStatus())));
    }
    if (volume.getName() != null) {
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.NAME.getName(),volume.getName()));
    }
 else {
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.NAME.getName(),"String_Node_Str"));
    }
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.ZONE_ID.getName(),Long.valueOf(volume.getDataCenterId()).toString()));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.ZONE_NAME.getName(),getManagementServer().findDataCenterById(volume.getDataCenterId()).getName()));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.TYPE.getName(),volume.getVolumeType()));
    if (volume.getDeviceId() != null)     volumeData.add(new Pair<String,Object>(BaseCmd.Properties.DEVICE_ID.getName(),Long.valueOf(volume.getDeviceId()).toString()));
    Long instanceId=volume.getInstanceId();
    if (instanceId != null) {
      VMInstanceVO vm=getManagementServer().findVMInstanceById(instanceId);
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.VIRTUAL_MACHINE_ID.getName(),vm.getId()));
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.VIRTUAL_MACHINE_NAME.getName(),vm.getName()));
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.VIRTUAL_MACHINE_DISPLAYNAME.getName(),vm.getName()));
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.VIRTUAL_MACHINE_STATE.getName(),vm.getState()));
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.DEVICE_ID.getName(),volume.getDeviceId()));
    }
    long virtualSizeInBytes=volume.getSize();
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.SIZE.getName(),virtualSizeInBytes));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.CREATED.getName(),getDateString(volume.getCreated())));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.ATTACHED.getName(),getDateString(volume.getAttached())));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.STATE.getName(),volume.getStatus()));
    Account accountTemp=getManagementServer().findAccountById(volume.getAccountId());
    if (accountTemp != null) {
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.ACCOUNT.getName(),accountTemp.getAccountName()));
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.DOMAIN_ID.getName(),accountTemp.getDomainId()));
      volumeData.add(new Pair<String,Object>(BaseCmd.Properties.DOMAIN.getName(),getManagementServer().findDomainIdById(accountTemp.getDomainId()).getName()));
    }
    String storageType;
    try {
      if (volume.getPoolId() == null) {
        storageType="String_Node_Str";
      }
 else {
        storageType=getManagementServer().volumeIsOnSharedStorage(volume.getId()) ? "String_Node_Str" : "String_Node_Str";
      }
    }
 catch (    InvalidParameterValueException e) {
      s_logger.error(e.getMessage(),e);
      throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"String_Node_Str" + volume.getName() + "String_Node_Str");
    }
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.STORAGE_TYPE.getName(),storageType));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.DISK_OFFERING_ID.getName(),volume.getDiskOfferingId()));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.DISK_OFFERING_NAME.getName(),getManagementServer().findDiskOfferingById(volume.getDiskOfferingId()).getName()));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.DISK_OFFERING_DISPLAY_TEXT.getName(),getManagementServer().findDiskOfferingById(volume.getDiskOfferingId()).getDisplayText()));
    Long poolId=volume.getPoolId();
    String poolName=(poolId == null) ? "String_Node_Str" : getManagementServer().findPoolById(poolId).getName();
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.STORAGE.getName(),poolName));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.SOURCE_ID.getName(),volume.getSourceId()));
    volumeData.add(new Pair<String,Object>(BaseCmd.Properties.SOURCE_TYPE.getName(),volume.getSourceType().toString()));
    vTag[i++]=volumeData;
  }
  Pair<String,Object> volumeTag=new Pair<String,Object>("String_Node_Str",vTag);
  volumeTags.add(volumeTag);
  return volumeTags;
}