CID-1114606 use of MAX_VALUE and longValue() on Integer

This commit is contained in:
Daan Hoogland 2015-01-06 16:24:29 +01:00
parent eb9fba4fea
commit e8a54f471c
2 changed files with 9 additions and 9 deletions

View File

@ -2020,14 +2020,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
}
}
if ((cpuNumber != null) && ((cpuNumber.intValue() <= 0) || (cpuNumber.intValue() > 2147483647))) {
throw new InvalidParameterValueException("Failed to create service offering " + name + ": specify the cpu number value between 1 and 2147483647");
if ((cpuNumber != null) && ((cpuNumber.intValue() <= 0) || (cpuNumber.longValue() > Integer.MAX_VALUE))) {
throw new InvalidParameterValueException("Failed to create service offering " + name + ": specify the cpu number value between 1 and " + Integer.MAX_VALUE);
}
if ((cpuSpeed != null) && ((cpuSpeed.intValue() < 0) || (cpuSpeed.intValue() > 2147483647))) {
throw new InvalidParameterValueException("Failed to create service offering " + name + ": specify the cpu speed value between 1 and 2147483647");
if ((cpuSpeed != null) && ((cpuSpeed.intValue() < 0) || (cpuSpeed.longValue() > Integer.MAX_VALUE))) {
throw new InvalidParameterValueException("Failed to create service offering " + name + ": specify the cpu speed value between 0 and " + Integer.MAX_VALUE);
}
if ((memory != null) && ((memory.intValue() < 32) || (memory.intValue() > 2147483647))) {
throw new InvalidParameterValueException("Failed to create service offering " + name + ": specify the memory value between 32 and 2147483647 MB");
if ((memory != null) && ((memory.intValue() < 32) || (memory.longValue() > Integer.MAX_VALUE))) {
throw new InvalidParameterValueException("Failed to create service offering " + name + ": specify the memory value between 32 and " + Integer.MAX_VALUE + " MB");
}
// check if valid domain

View File

@ -882,7 +882,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
if (serviceOffering.getCpu() == null) {
String cpuNumber = customParameters.get(UsageEventVO.DynamicParameters.cpuNumber.name());
if ((cpuNumber == null) || (NumbersUtil.parseInt(cpuNumber, -1) <= 0)) {
throw new InvalidParameterValueException("Invalid cpu cores value, specify a value between 1 and 2147483647");
throw new InvalidParameterValueException("Invalid cpu cores value, specify a value between 1 and " + Integer.MAX_VALUE);
}
} else if (customParameters.containsKey(UsageEventVO.DynamicParameters.cpuNumber.name())) {
throw new InvalidParameterValueException("The cpu cores of this offering id:" + serviceOffering.getId()
@ -892,7 +892,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
if (serviceOffering.getSpeed() == null) {
String cpuSpeed = customParameters.get(UsageEventVO.DynamicParameters.cpuSpeed.name());
if ((cpuSpeed == null) || (NumbersUtil.parseInt(cpuSpeed, -1) <= 0)) {
throw new InvalidParameterValueException("Invalid cpu speed value, specify a value between 1 and 2147483647");
throw new InvalidParameterValueException("Invalid cpu speed value, specify a value between 1 and " + Integer.MAX_VALUE);
}
} else if (customParameters.containsKey(UsageEventVO.DynamicParameters.cpuSpeed.name())) {
throw new InvalidParameterValueException("The cpu speed of this offering id:" + serviceOffering.getId()
@ -902,7 +902,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
if (serviceOffering.getRamSize() == null) {
String memory = customParameters.get(UsageEventVO.DynamicParameters.memory.name());
if (memory == null || (NumbersUtil.parseInt(memory, -1) < 32)) {
throw new InvalidParameterValueException("Invalid memory value, specify a value between 32 and 2147483647 MB");
throw new InvalidParameterValueException("Invalid memory value, specify a value between 32 and " + Integer.MAX_VALUE + " MB");
}
} else if (customParameters.containsKey(UsageEventVO.DynamicParameters.memory.name())) {
throw new InvalidParameterValueException("The memory of this offering id:" + serviceOffering.getId() + " is not customizable. This is predefined in the template.");