Ray Milkey
Committed by Gerrit Code Review

More ONOS-1612 - Fix NPEs if compenent lookup fails

Change-Id: Icc881cc79e75b7c44bcaa925b266396a93b60dbe
......@@ -107,6 +107,11 @@ public class ComponentConfigCommand extends AbstractShellCommand {
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()) {
......
......@@ -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;
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 @@ public class ComponentPropertyNameCompleter implements Completer {
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);
......