This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch 4.20
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.20 by this push:
new c748b69e70c Fix NPE during public IP listing when a removed network or
VPC ID is informed for associatenetworkid parameter (#12372)
c748b69e70c is described below
commit c748b69e70ce97a18ea8ac5c0157364c76a52b97
Author: Erik Böck <[email protected]>
AuthorDate: Mon Feb 23 09:03:36 2026 -0300
Fix NPE during public IP listing when a removed network or VPC ID is
informed for associatenetworkid parameter (#12372)
---
.../com/cloud/server/ManagementServerImpl.java | 33 +++++++++++++++-------
1 file changed, 23 insertions(+), 10 deletions(-)
diff --git a/server/src/main/java/com/cloud/server/ManagementServerImpl.java
b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
index caf94a1cc85..bd4c311e3cd 100644
--- a/server/src/main/java/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
@@ -44,6 +44,7 @@ import javax.crypto.spec.SecretKeySpec;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
+import com.cloud.network.vpc.VpcVO;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.SecurityChecker;
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
@@ -2580,12 +2581,21 @@ public class ManagementServerImpl extends ManagerBase
implements ManagementServe
}
if (associatedNetworkId != null) {
- _accountMgr.checkAccess(caller, null, false,
networkDao.findById(associatedNetworkId));
- sc.setParameters("associatedNetworkIdEq", associatedNetworkId);
+ NetworkVO associatedNetwork =
networkDao.findById(associatedNetworkId);
+
+ if (associatedNetwork != null) {
+ _accountMgr.checkAccess(caller, null, false,
associatedNetwork);
+ sc.setParameters("associatedNetworkIdEq", associatedNetworkId);
+ }
}
+
if (vpcId != null) {
- _accountMgr.checkAccess(caller, null, false,
_vpcDao.findById(vpcId));
- sc.setParameters("vpcId", vpcId);
+ VpcVO vpc = _vpcDao.findById(vpcId);
+
+ if (vpc != null) {
+ _accountMgr.checkAccess(caller, null, false, vpc);
+ sc.setParameters("vpcId", vpcId);
+ }
}
addrs = _publicIpAddressDao.search(sc, searchFilter); // Allocated
@@ -2602,13 +2612,16 @@ public class ManagementServerImpl extends ManagerBase
implements ManagementServe
}
if (associatedNetworkId != null) {
NetworkVO guestNetwork =
networkDao.findById(associatedNetworkId);
- if (zoneId == null) {
- zoneId = guestNetwork.getDataCenterId();
- } else if (zoneId != guestNetwork.getDataCenterId()) {
- InvalidParameterValueException ex = new
InvalidParameterValueException("Please specify a valid associated network id in
the specified zone.");
- throw ex;
+
+ if (guestNetwork != null) {
+ if (zoneId == null) {
+ zoneId = guestNetwork.getDataCenterId();
+ } else if (zoneId != guestNetwork.getDataCenterId()) {
+ InvalidParameterValueException ex = new
InvalidParameterValueException("Please specify a valid associated network id in
the specified zone.");
+ throw ex;
+ }
+ owner = _accountDao.findById(guestNetwork.getAccountId());
}
- owner = _accountDao.findById(guestNetwork.getAccountId());
}
List<DataCenterVO> dcList = new ArrayList<>();
if (zoneId == null){