server: Fix NPE while deleting a domain (#5753)

* server: Fix NPE while deleting a domain

While deleting a domain, if vlan ip range cant be found
then this will throw NPE. Just return false if vlan ip
range cant be found

* return true if vlan is not found

* change output message

Co-authored-by: Rakesh Venkatesh <rakeshv@apache.org>
This commit is contained in:
Rakesh 2021-12-27 20:51:43 +01:00 committed by GitHub
parent 9607ae9639
commit 8ba5b92a83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4922,7 +4922,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
public boolean releasePublicIpRange(final long vlanDbId, final long userId, final Account caller) {
VlanVO vlan = _vlanDao.findById(vlanDbId);
if(vlan == null) {
s_logger.warn("VLAN information for Account '" + caller + "', User '" + userId + "' VLAN '" + vlanDbId + "' is null. This is NPE situation.");
// Nothing to do if vlan can't be found
s_logger.warn(String.format("Skipping the process for releasing public IP range as could not find a VLAN with ID '%s' for Account '%s' and User '%s'."
,vlanDbId, caller, userId));
return true;
}
// Verify range is dedicated
@ -4989,13 +4992,15 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
}
// decrement resource count for dedicated public ip's
_resourceLimitMgr.decrementResourceCount(acctVln.get(0).getAccountId(), ResourceType.public_ip, new Long(ips.size()));
return true;
success = true;
} else if (isDomainSpecific && _domainVlanMapDao.remove(domainVlan.get(0).getId())) {
s_logger.debug("Remove the vlan from domain_vlan_map successfully.");
return true;
success = true;
} else {
return false;
success = false;
}
return success;
}
@DB