From 629053d2f1c019724dc00d28545ef4fc6e2f1ef4 Mon Sep 17 00:00:00 2001 From: Vijay Date: Thu, 19 Jul 2012 08:55:36 +0530 Subject: [PATCH] AutoScale. Catching an odd case to get rid of null pointer exception --- server/src/com/cloud/network/as/AutoScaleManagerImpl.java | 6 ++++++ server/src/com/cloud/network/element/NetscalerElement.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java index cd73137bc62..4d4fb80d5e4 100644 --- a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java +++ b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java @@ -615,6 +615,12 @@ public class AutoScaleManagerImpl implements AutoScaleService, Manager { List 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"); } diff --git a/server/src/com/cloud/network/element/NetscalerElement.java b/server/src/com/cloud/network/element/NetscalerElement.java index ce51ef5514b..437aa0557d2 100644 --- a/server/src/com/cloud/network/element/NetscalerElement.java +++ b/server/src/com/cloud/network/element/NetscalerElement.java @@ -600,7 +600,7 @@ StaticNatServiceProvider { int srcPort = rule.getSourcePortStart(); List 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());