AutoScale. Catching an odd case to get rid of null pointer exception

This commit is contained in:
Vijay 2012-07-19 08:55:36 +05:30
parent dc77c8caa5
commit 629053d2f1
2 changed files with 7 additions and 1 deletions

View File

@ -615,6 +615,12 @@ public class AutoScaleManagerImpl<Type> implements AutoScaleService, Manager {
List<AutoScaleVmGroupPolicyMapVO> vmGroupPolicyList = _autoScaleVmGroupPolicyMapDao.listByPolicyId(policyId);
for (AutoScaleVmGroupPolicyMapVO vmGroupPolicy : vmGroupPolicyList) {
AutoScaleVmGroupVO vmGroupVO = _autoScaleVmGroupDao.findById(vmGroupPolicy.getVmGroupId());
if(vmGroupVO == null) {
s_logger.warn("Stale database entry! There is an entry in VmGroupPolicyMap but the vmGroup is missing:" + vmGroupPolicy.getVmGroupId());
continue;
}
if (!vmGroupVO.getState().equals(AutoScaleVmGroup.State_Disabled)) {
throw new InvalidParameterValueException("The AutoScale Policy can be updated only if the Vm Group it is associated with is disabled in state");
}

View File

@ -600,7 +600,7 @@ StaticNatServiceProvider {
int srcPort = rule.getSourcePortStart();
List<LbDestination> destinations = rule.getDestinations();
if (destinations != null && !destinations.isEmpty() || rule.isAutoScaleConfig()) {
if ((destinations != null && !destinations.isEmpty()) || rule.isAutoScaleConfig()) {
LoadBalancerTO loadBalancer = new LoadBalancerTO(rule.getId(), srcIp, srcPort, protocol, algorithm, revoked, false, destinations, rule.getStickinessPolicies());
if(rule.isAutoScaleConfig()) {
loadBalancer.setAutoScaleVmGroup(rule.getAutoScaleVmGroup());