VPC: fixed NPE in network ACL delete (ip address is null for the rule of this type_

This commit is contained in:
Alena Prokharchyk 2012-06-22 15:06:09 -07:00
parent 030458a37b
commit d3ccc3a7de
1 changed files with 5 additions and 5 deletions

View File

@ -420,15 +420,15 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
@DB
protected void removeRule(FirewallRule rule) {
//Lock ip address
IpAddress ip = _ipAddressDao.findById(rule.getSourceIpAddressId());
Transaction txn = Transaction.currentTxn();
txn.start();
//remove the rule
_firewallDao.remove(rule.getId());
if (ip.getVpcId() != null && _firewallDao.listByIp(ip.getId()).isEmpty()) {
//if the rule is the last one for the ip address assigned to VPC, unassign it from the network
//if the rule is the last one for the ip address assigned to VPC, unassign it from the network
IpAddress ip = _ipAddressDao.findById(rule.getSourceIpAddressId());
if (ip != null && ip.getVpcId() != null && _firewallDao.listByIp(ip.getId()).isEmpty()) {
_networkMgr.unassignIPFromVpcNetwork(ip.getId());
}