This is an automated email from the ASF dual-hosted git repository.
sureshanaparti pushed a commit to branch 4.16
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.16 by this push:
new 9607ae9 server: Fix NPE while adding network to VPC (#5723)
9607ae9 is described below
commit 9607ae96392d766d7f09b59f4a1dac67fcef1a08
Author: Rakesh <[email protected]>
AuthorDate: Sat Dec 25 15:27:18 2021 +0100
server: Fix NPE while adding network to VPC (#5723)
* server: Fix NPE while adding network to VPC
Sometimes adding network to VPC fails because of libirt error.
In that case the new network wont have any VR's associated with it
and hence it will return null.
* use collectionutils
Co-authored-by: Rakesh Venkatesh <[email protected]>
---
.../main/java/com/cloud/network/element/VpcVirtualRouterElement.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git
a/server/src/main/java/com/cloud/network/element/VpcVirtualRouterElement.java
b/server/src/main/java/com/cloud/network/element/VpcVirtualRouterElement.java
index 377f18a..b674696 100644
---
a/server/src/main/java/com/cloud/network/element/VpcVirtualRouterElement.java
+++
b/server/src/main/java/com/cloud/network/element/VpcVirtualRouterElement.java
@@ -73,6 +73,7 @@ import com.cloud.vm.VirtualMachineManager;
import com.cloud.vm.VirtualMachineProfile;
import org.apache.cloudstack.network.topology.NetworkTopology;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;
import org.cloud.network.router.deployment.RouterDeploymentDefinition;
import org.cloud.network.router.deployment.RouterDeploymentDefinitionBuilder;
@@ -348,7 +349,7 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
//1st time it runs the domain router of the VM shall be returned
List<DomainRouterVO> routers = super.getRouters(network, dest);
- if (routers.size() > 0) {
+ if (CollectionUtils.isNotEmpty(routers)) {
return routers;
}
@@ -712,4 +713,4 @@ public class VpcVirtualRouterElement extends
VirtualRouterElement implements Vpc
}
return result;
}
-}
\ No newline at end of file
+}