Program: 106143
Project: 106143
Buggy source:
@Override public void setResourceLimits(AccountJoinVO account,boolean accountIsAdmin,ResourceLimitAndCountResponse response){
  long vmLimit=ApiDBUtils.findCorrectResourceLimit(account.getVmLimit(),account.getId(),ResourceType.user_vm);
  String vmLimitDisplay=(accountIsAdmin || vmLimit == -1) ? "String_Node_Str" : String.valueOf(vmLimit);
  long vmTotal=(account.getVmTotal() == null) ? 0 : account.getVmTotal();
  String vmAvail=(accountIsAdmin || vmLimit == -1) ? "String_Node_Str" : String.valueOf(vmLimit - vmTotal);
  response.setVmLimit(vmLimitDisplay);
  response.setVmTotal(vmTotal);
  response.setVmAvailable(vmAvail);
  long ipLimit=ApiDBUtils.findCorrectResourceLimit(account.getIpLimit(),account.getType(),ResourceType.public_ip);
  String ipLimitDisplay=(accountIsAdmin || ipLimit == -1) ? "String_Node_Str" : String.valueOf(ipLimit);
  long ipTotal=(account.getIpTotal() == null) ? 0 : account.getIpTotal();
  Long ips=ipLimit - ipTotal;
  Long ipsLeft=account.getIpFree();
  boolean unlimited=true;
  if (ips.longValue() > ipsLeft.longValue()) {
    ips=ipsLeft;
    unlimited=false;
  }
  String ipAvail=((accountIsAdmin || ipLimit == -1) && unlimited) ? "String_Node_Str" : String.valueOf(ips);
  response.setIpLimit(ipLimitDisplay);
  response.setIpTotal(ipTotal);
  response.setIpAvailable(ipAvail);
  long volumeLimit=ApiDBUtils.findCorrectResourceLimit(account.getVolumeLimit(),account.getType(),ResourceType.volume);
  String volumeLimitDisplay=(accountIsAdmin || volumeLimit == -1) ? "String_Node_Str" : String.valueOf(volumeLimit);
  long volumeTotal=(account.getVolumeTotal() == 0) ? 0 : account.getVolumeTotal();
  String volumeAvail=(accountIsAdmin || volumeLimit == -1) ? "String_Node_Str" : String.valueOf(volumeLimit - volumeTotal);
  response.setVolumeLimit(volumeLimitDisplay);
  response.setVolumeTotal(volumeTotal);
  response.setVolumeAvailable(volumeAvail);
  long snapshotLimit=ApiDBUtils.findCorrectResourceLimit(account.getSnapshotLimit(),account.getType(),ResourceType.snapshot);
  String snapshotLimitDisplay=(accountIsAdmin || snapshotLimit == -1) ? "String_Node_Str" : String.valueOf(snapshotLimit);
  long snapshotTotal=(account.getSnapshotTotal() == null) ? 0 : account.getSnapshotTotal();
  String snapshotAvail=(accountIsAdmin || snapshotLimit == -1) ? "String_Node_Str" : String.valueOf(snapshotLimit - snapshotTotal);
  response.setSnapshotLimit(snapshotLimitDisplay);
  response.setSnapshotTotal(snapshotTotal);
  response.setSnapshotAvailable(snapshotAvail);
  Long templateLimit=ApiDBUtils.findCorrectResourceLimit(account.getTemplateLimit(),account.getType(),ResourceType.template);
  String templateLimitDisplay=(accountIsAdmin || templateLimit == -1) ? "String_Node_Str" : String.valueOf(templateLimit);
  Long templateTotal=(account.getTemplateTotal() == null) ? 0 : account.getTemplateTotal();
  String templateAvail=(accountIsAdmin || templateLimit == -1) ? "String_Node_Str" : String.valueOf(templateLimit - templateTotal);
  response.setTemplateLimit(templateLimitDisplay);
  response.setTemplateTotal(templateTotal);
  response.setTemplateAvailable(templateAvail);
  response.setVmStopped(account.getVmStopped());
  response.setVmRunning(account.getVmRunning());
  long networkLimit=ApiDBUtils.findCorrectResourceLimit(account.getNetworkLimit(),account.getType(),ResourceType.network);
  String networkLimitDisplay=(accountIsAdmin || networkLimit == -1) ? "String_Node_Str" : String.valueOf(networkLimit);
  long networkTotal=(account.getNetworkTotal() == null) ? 0 : account.getNetworkTotal();
  String networkAvail=(accountIsAdmin || networkLimit == -1) ? "String_Node_Str" : String.valueOf(networkLimit - networkTotal);
  response.setNetworkLimit(networkLimitDisplay);
  response.setNetworkTotal(networkTotal);
  response.setNetworkAvailable(networkAvail);
  long vpcLimit=ApiDBUtils.findCorrectResourceLimit(account.getVpcLimit(),account.getType(),ResourceType.vpc);
  String vpcLimitDisplay=(accountIsAdmin || vpcLimit == -1) ? "String_Node_Str" : String.valueOf(vpcLimit);
  long vpcTotal=(account.getVpcTotal() == null) ? 0 : account.getVpcTotal();
  String vpcAvail=(accountIsAdmin || vpcLimit == -1) ? "String_Node_Str" : String.valueOf(vpcLimit - vpcTotal);
  response.setVpcLimit(vpcLimitDisplay);
  response.setVpcTotal(vpcTotal);
  response.setVpcAvailable(vpcAvail);
  long cpuLimit=ApiDBUtils.findCorrectResourceLimit(account.getCpuLimit(),account.getType(),ResourceType.cpu);
  String cpuLimitDisplay=(accountIsAdmin || cpuLimit == -1) ? "String_Node_Str" : String.valueOf(cpuLimit);
  long cpuTotal=(account.getCpuTotal() == null) ? 0 : account.getCpuTotal();
  String cpuAvail=(accountIsAdmin || cpuLimit == -1) ? "String_Node_Str" : String.valueOf(cpuLimit - cpuTotal);
  response.setCpuLimit(cpuLimitDisplay);
  response.setCpuTotal(cpuTotal);
  response.setCpuAvailable(cpuAvail);
  long memoryLimit=ApiDBUtils.findCorrectResourceLimit(account.getMemoryLimit(),account.getType(),ResourceType.memory);
  String memoryLimitDisplay=(accountIsAdmin || memoryLimit == -1) ? "String_Node_Str" : String.valueOf(memoryLimit);
  long memoryTotal=(account.getMemoryTotal() == null) ? 0 : account.getMemoryTotal();
  String memoryAvail=(accountIsAdmin || memoryLimit == -1) ? "String_Node_Str" : String.valueOf(memoryLimit - memoryTotal);
  response.setMemoryLimit(memoryLimitDisplay);
  response.setMemoryTotal(memoryTotal);
  response.setMemoryAvailable(memoryAvail);
  long primaryStorageLimit=ApiDBUtils.findCorrectResourceLimit(account.getPrimaryStorageLimit(),account.getType(),ResourceType.primary_storage);
  String primaryStorageLimitDisplay=(accountIsAdmin || primaryStorageLimit == -1) ? "String_Node_Str" : String.valueOf(primaryStorageLimit / ResourceType.bytesToGiB);
  long primaryStorageTotal=(account.getPrimaryStorageTotal() == null) ? 0 : (account.getPrimaryStorageTotal() / ResourceType.bytesToGiB);
  String primaryStorageAvail=(accountIsAdmin || primaryStorageLimit == -1) ? "String_Node_Str" : String.valueOf((primaryStorageLimit / ResourceType.bytesToGiB) - primaryStorageTotal);
  response.setPrimaryStorageLimit(primaryStorageLimitDisplay);
  response.setPrimaryStorageTotal(primaryStorageTotal);
  response.setPrimaryStorageAvailable(primaryStorageAvail);
  long secondaryStorageLimit=ApiDBUtils.findCorrectResourceLimit(account.getSecondaryStorageLimit(),account.getType(),ResourceType.secondary_storage);
  String secondaryStorageLimitDisplay=(accountIsAdmin || secondaryStorageLimit == -1) ? "String_Node_Str" : String.valueOf(secondaryStorageLimit / ResourceType.bytesToGiB);
  long secondaryStorageTotal=(account.getSecondaryStorageTotal() == null) ? 0 : (account.getSecondaryStorageTotal() / ResourceType.bytesToGiB);
  String secondaryStorageAvail=(accountIsAdmin || secondaryStorageLimit == -1) ? "String_Node_Str" : String.valueOf((secondaryStorageLimit / ResourceType.bytesToGiB) - secondaryStorageTotal);
  response.setSecondaryStorageLimit(secondaryStorageLimitDisplay);
  response.setSecondaryStorageTotal(secondaryStorageTotal);
  response.setSecondaryStorageAvailable(secondaryStorageAvail);
}

Fixed version (ground truth):
@Override public void setResourceLimits(AccountJoinVO account,boolean accountIsAdmin,ResourceLimitAndCountResponse response){
  long vmLimit=ApiDBUtils.findCorrectResourceLimit(account.getVmLimit(),account.getId(),ResourceType.user_vm);
  String vmLimitDisplay=(accountIsAdmin || vmLimit == -1) ? "String_Node_Str" : String.valueOf(vmLimit);
  long vmTotal=(account.getVmTotal() == null) ? 0 : account.getVmTotal();
  String vmAvail=(accountIsAdmin || vmLimit == -1) ? "String_Node_Str" : String.valueOf(vmLimit - vmTotal);
  response.setVmLimit(vmLimitDisplay);
  response.setVmTotal(vmTotal);
  response.setVmAvailable(vmAvail);
  long ipLimit=ApiDBUtils.findCorrectResourceLimit(account.getIpLimit(),account.getId(),ResourceType.public_ip);
  String ipLimitDisplay=(accountIsAdmin || ipLimit == -1) ? "String_Node_Str" : String.valueOf(ipLimit);
  long ipTotal=(account.getIpTotal() == null) ? 0 : account.getIpTotal();
  Long ips=ipLimit - ipTotal;
  Long ipsLeft=account.getIpFree();
  boolean unlimited=true;
  if (ips.longValue() > ipsLeft.longValue()) {
    ips=ipsLeft;
    unlimited=false;
  }
  String ipAvail=((accountIsAdmin || ipLimit == -1) && unlimited) ? "String_Node_Str" : String.valueOf(ips);
  response.setIpLimit(ipLimitDisplay);
  response.setIpTotal(ipTotal);
  response.setIpAvailable(ipAvail);
  long volumeLimit=ApiDBUtils.findCorrectResourceLimit(account.getVolumeLimit(),account.getId(),ResourceType.volume);
  String volumeLimitDisplay=(accountIsAdmin || volumeLimit == -1) ? "String_Node_Str" : String.valueOf(volumeLimit);
  long volumeTotal=(account.getVolumeTotal() == 0) ? 0 : account.getVolumeTotal();
  String volumeAvail=(accountIsAdmin || volumeLimit == -1) ? "String_Node_Str" : String.valueOf(volumeLimit - volumeTotal);
  response.setVolumeLimit(volumeLimitDisplay);
  response.setVolumeTotal(volumeTotal);
  response.setVolumeAvailable(volumeAvail);
  long snapshotLimit=ApiDBUtils.findCorrectResourceLimit(account.getSnapshotLimit(),account.getId(),ResourceType.snapshot);
  String snapshotLimitDisplay=(accountIsAdmin || snapshotLimit == -1) ? "String_Node_Str" : String.valueOf(snapshotLimit);
  long snapshotTotal=(account.getSnapshotTotal() == null) ? 0 : account.getSnapshotTotal();
  String snapshotAvail=(accountIsAdmin || snapshotLimit == -1) ? "String_Node_Str" : String.valueOf(snapshotLimit - snapshotTotal);
  response.setSnapshotLimit(snapshotLimitDisplay);
  response.setSnapshotTotal(snapshotTotal);
  response.setSnapshotAvailable(snapshotAvail);
  Long templateLimit=ApiDBUtils.findCorrectResourceLimit(account.getTemplateLimit(),account.getId(),ResourceType.template);
  String templateLimitDisplay=(accountIsAdmin || templateLimit == -1) ? "String_Node_Str" : String.valueOf(templateLimit);
  Long templateTotal=(account.getTemplateTotal() == null) ? 0 : account.getTemplateTotal();
  String templateAvail=(accountIsAdmin || templateLimit == -1) ? "String_Node_Str" : String.valueOf(templateLimit - templateTotal);
  response.setTemplateLimit(templateLimitDisplay);
  response.setTemplateTotal(templateTotal);
  response.setTemplateAvailable(templateAvail);
  response.setVmStopped(account.getVmStopped());
  response.setVmRunning(account.getVmRunning());
  long networkLimit=ApiDBUtils.findCorrectResourceLimit(account.getNetworkLimit(),account.getId(),ResourceType.network);
  String networkLimitDisplay=(accountIsAdmin || networkLimit == -1) ? "String_Node_Str" : String.valueOf(networkLimit);
  long networkTotal=(account.getNetworkTotal() == null) ? 0 : account.getNetworkTotal();
  String networkAvail=(accountIsAdmin || networkLimit == -1) ? "String_Node_Str" : String.valueOf(networkLimit - networkTotal);
  response.setNetworkLimit(networkLimitDisplay);
  response.setNetworkTotal(networkTotal);
  response.setNetworkAvailable(networkAvail);
  long vpcLimit=ApiDBUtils.findCorrectResourceLimit(account.getVpcLimit(),account.getId(),ResourceType.vpc);
  String vpcLimitDisplay=(accountIsAdmin || vpcLimit == -1) ? "String_Node_Str" : String.valueOf(vpcLimit);
  long vpcTotal=(account.getVpcTotal() == null) ? 0 : account.getVpcTotal();
  String vpcAvail=(accountIsAdmin || vpcLimit == -1) ? "String_Node_Str" : String.valueOf(vpcLimit - vpcTotal);
  response.setVpcLimit(vpcLimitDisplay);
  response.setVpcTotal(vpcTotal);
  response.setVpcAvailable(vpcAvail);
  long cpuLimit=ApiDBUtils.findCorrectResourceLimit(account.getCpuLimit(),account.getId(),ResourceType.cpu);
  String cpuLimitDisplay=(accountIsAdmin || cpuLimit == -1) ? "String_Node_Str" : String.valueOf(cpuLimit);
  long cpuTotal=(account.getCpuTotal() == null) ? 0 : account.getCpuTotal();
  String cpuAvail=(accountIsAdmin || cpuLimit == -1) ? "String_Node_Str" : String.valueOf(cpuLimit - cpuTotal);
  response.setCpuLimit(cpuLimitDisplay);
  response.setCpuTotal(cpuTotal);
  response.setCpuAvailable(cpuAvail);
  long memoryLimit=ApiDBUtils.findCorrectResourceLimit(account.getMemoryLimit(),account.getId(),ResourceType.memory);
  String memoryLimitDisplay=(accountIsAdmin || memoryLimit == -1) ? "String_Node_Str" : String.valueOf(memoryLimit);
  long memoryTotal=(account.getMemoryTotal() == null) ? 0 : account.getMemoryTotal();
  String memoryAvail=(accountIsAdmin || memoryLimit == -1) ? "String_Node_Str" : String.valueOf(memoryLimit - memoryTotal);
  response.setMemoryLimit(memoryLimitDisplay);
  response.setMemoryTotal(memoryTotal);
  response.setMemoryAvailable(memoryAvail);
  long primaryStorageLimit=ApiDBUtils.findCorrectResourceLimit(account.getPrimaryStorageLimit(),account.getId(),ResourceType.primary_storage);
  String primaryStorageLimitDisplay=(accountIsAdmin || primaryStorageLimit == -1) ? "String_Node_Str" : String.valueOf(primaryStorageLimit / ResourceType.bytesToGiB);
  long primaryStorageTotal=(account.getPrimaryStorageTotal() == null) ? 0 : (account.getPrimaryStorageTotal() / ResourceType.bytesToGiB);
  String primaryStorageAvail=(accountIsAdmin || primaryStorageLimit == -1) ? "String_Node_Str" : String.valueOf((primaryStorageLimit / ResourceType.bytesToGiB) - primaryStorageTotal);
  response.setPrimaryStorageLimit(primaryStorageLimitDisplay);
  response.setPrimaryStorageTotal(primaryStorageTotal);
  response.setPrimaryStorageAvailable(primaryStorageAvail);
  long secondaryStorageLimit=ApiDBUtils.findCorrectResourceLimit(account.getSecondaryStorageLimit(),account.getId(),ResourceType.secondary_storage);
  String secondaryStorageLimitDisplay=(accountIsAdmin || secondaryStorageLimit == -1) ? "String_Node_Str" : String.valueOf(secondaryStorageLimit / ResourceType.bytesToGiB);
  long secondaryStorageTotal=(account.getSecondaryStorageTotal() == null) ? 0 : (account.getSecondaryStorageTotal() / ResourceType.bytesToGiB);
  String secondaryStorageAvail=(accountIsAdmin || secondaryStorageLimit == -1) ? "String_Node_Str" : String.valueOf((secondaryStorageLimit / ResourceType.bytesToGiB) - secondaryStorageTotal);
  response.setSecondaryStorageLimit(secondaryStorageLimitDisplay);
  response.setSecondaryStorageTotal(secondaryStorageTotal);
  response.setSecondaryStorageAvailable(secondaryStorageAvail);
}