Skip to content

Commit 3e34da6

Browse files
committed
Fix NPE when listing public IPs associated to removed networks or VPCs
1 parent 4628385 commit 3e34da6

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

server/src/main/java/com/cloud/server/ManagementServerImpl.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import javax.inject.Inject;
4444
import javax.naming.ConfigurationException;
4545

46+
import com.cloud.network.vpc.VpcVO;
4647
import org.apache.cloudstack.acl.ControlledEntity;
4748
import org.apache.cloudstack.acl.SecurityChecker;
4849
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
@@ -2648,12 +2649,21 @@ public Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(final ListP
26482649
}
26492650

26502651
if (associatedNetworkId != null) {
2651-
_accountMgr.checkAccess(caller, null, false, networkDao.findById(associatedNetworkId));
2652-
sc.setParameters("associatedNetworkIdEq", associatedNetworkId);
2652+
NetworkVO associatedNetwork = networkDao.findById(associatedNetworkId);
2653+
2654+
if (associatedNetwork != null) {
2655+
_accountMgr.checkAccess(caller, null, false, associatedNetwork);
2656+
sc.setParameters("associatedNetworkIdEq", associatedNetworkId);
2657+
}
26532658
}
2659+
26542660
if (vpcId != null) {
2655-
_accountMgr.checkAccess(caller, null, false, _vpcDao.findById(vpcId));
2656-
sc.setParameters("vpcId", vpcId);
2661+
VpcVO vpc = _vpcDao.findById(vpcId);
2662+
2663+
if (vpc != null) {
2664+
_accountMgr.checkAccess(caller, null, false, vpc);
2665+
sc.setParameters("vpcId", vpcId);
2666+
}
26572667
}
26582668

26592669
addrs = _publicIpAddressDao.search(sc, searchFilter); // Allocated

0 commit comments

Comments
 (0)