Skip to content

Commit 3363136

Browse files
committed
fix NPE in other associatenetworkid parameter use
1 parent 0d2f34a commit 3363136

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,13 +2612,16 @@ public Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(final ListP
26122612
}
26132613
if (associatedNetworkId != null) {
26142614
NetworkVO guestNetwork = networkDao.findById(associatedNetworkId);
2615-
if (zoneId == null) {
2616-
zoneId = guestNetwork.getDataCenterId();
2617-
} else if (zoneId != guestNetwork.getDataCenterId()) {
2618-
InvalidParameterValueException ex = new InvalidParameterValueException("Please specify a valid associated network id in the specified zone.");
2619-
throw ex;
2615+
2616+
if (guestNetwork != null) {
2617+
if (zoneId == null) {
2618+
zoneId = guestNetwork.getDataCenterId();
2619+
} else if (zoneId != guestNetwork.getDataCenterId()) {
2620+
InvalidParameterValueException ex = new InvalidParameterValueException("Please specify a valid associated network id in the specified zone.");
2621+
throw ex;
2622+
}
2623+
owner = _accountDao.findById(guestNetwork.getAccountId());
26202624
}
2621-
owner = _accountDao.findById(guestNetwork.getAccountId());
26222625
}
26232626
List<DataCenterVO> dcList = new ArrayList<>();
26242627
if (zoneId == null){

0 commit comments

Comments
 (0)