More ONOS-1612 - Fix NPEs if compenent lookup fails
Change-Id: Icc881cc79e75b7c44bcaa925b266396a93b60dbe
diff --git a/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java b/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java
index b1e5150..e580503 100644
--- a/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java
@@ -107,6 +107,11 @@
private void listComponentProperty(String component, String name) {
Set<ConfigProperty> props = service.getProperties(component);
+
+ if (props == null) {
+ return;
+ }
+
Optional<ConfigProperty> property = props.stream()
.filter(p -> p.name().equals(name)).findFirst();
if (!property.isPresent()) {
diff --git a/cli/src/main/java/org/onosproject/cli/cfg/ComponentPropertyNameCompleter.java b/cli/src/main/java/org/onosproject/cli/cfg/ComponentPropertyNameCompleter.java
index db015f1..5b72493 100644
--- a/cli/src/main/java/org/onosproject/cli/cfg/ComponentPropertyNameCompleter.java
+++ b/cli/src/main/java/org/onosproject/cli/cfg/ComponentPropertyNameCompleter.java
@@ -16,6 +16,7 @@
package org.onosproject.cli.cfg;
import java.util.List;
+import java.util.Set;
import java.util.SortedSet;
import org.apache.felix.service.command.CommandSession;
@@ -24,6 +25,7 @@
import org.apache.karaf.shell.console.completer.ArgumentCompleter;
import org.apache.karaf.shell.console.completer.StringsCompleter;
import org.onosproject.cfg.ComponentConfigService;
+import org.onosproject.cfg.ConfigProperty;
import org.onosproject.cli.AbstractShellCommand;
/**
@@ -46,8 +48,11 @@
AbstractShellCommand.get(ComponentConfigService.class);
SortedSet<String> strings = delegate.getStrings();
- service.getProperties(componentName)
- .forEach(property -> strings.add(property.name()));
+ Set<ConfigProperty> properties =
+ service.getProperties(componentName);
+ if (properties != null) {
+ properties.forEach(property -> strings.add(property.name()));
+ }
// Now let the completer do the work for figuring out what to offer.
return delegate.complete(buffer, cursor, candidates);