commit | 8c553eb3170163b85612e6fb01aa5de7ac08c074 | [log] [tgz] |
---|---|---|
author | Jian Li <pyguni@gmail.com> | Thu Mar 04 18:48:39 2021 +0900 |
committer | Jian Li <pyguni@gmail.com> | Thu Mar 04 10:30:36 2021 +0000 |
tree | a6e5dbd41a6e0a915a6cf455a992f7ea0016ac54 | |
parent | b636f7046f091b4d426f3718e88d508133cd1c9a [diff] |
Fix: resolve a NPE caused by empty name list input in kubevirt CLI Change-Id: I1df88be7d456ab341a6620f0a0c77354dd1589a5
diff --git a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/cli/KubevirtShowPodCommand.java b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/cli/KubevirtShowPodCommand.java index 5f7bc4c..514e651 100644 --- a/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/cli/KubevirtShowPodCommand.java +++ b/apps/kubevirt-networking/app/src/main/java/org/onosproject/kubevirtnetworking/cli/KubevirtShowPodCommand.java
@@ -49,6 +49,11 @@ protected void doExecute() throws Exception { KubevirtPodService service = get(KubevirtPodService.class); + if (names == null || names.size() == 0) { + print("Need to specify at least one POD name using --name option."); + return; + } + for (String name : names) { Pod pod = service.pods().stream().filter(p -> p.getMetadata().getName().equals(name)) .findAny().orElse(null);
diff --git a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/cli/KubevirtShowNodeCommand.java b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/cli/KubevirtShowNodeCommand.java index 00699a0..5884b8d 100644 --- a/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/cli/KubevirtShowNodeCommand.java +++ b/apps/kubevirt-node/app/src/main/java/org/onosproject/kubevirtnode/cli/KubevirtShowNodeCommand.java
@@ -46,6 +46,11 @@ protected void doExecute() throws Exception { KubevirtNodeService service = get(KubevirtNodeService.class); + if (names == null || names.size() == 0) { + print("Need to specify at least one node name using --name option."); + return; + } + for (String name : names) { KubevirtNode node = service.node(name); if (node == null) {