Committed by
Gerrit Code Review
More ONOS-1612 - Fix NPEs if compenent lookup fails
Change-Id: Icc881cc79e75b7c44bcaa925b266396a93b60dbe
Showing
2 changed files
with
12 additions
and
2 deletions
... | @@ -107,6 +107,11 @@ public class ComponentConfigCommand extends AbstractShellCommand { | ... | @@ -107,6 +107,11 @@ public class ComponentConfigCommand extends AbstractShellCommand { |
107 | 107 | ||
108 | private void listComponentProperty(String component, String name) { | 108 | private void listComponentProperty(String component, String name) { |
109 | Set<ConfigProperty> props = service.getProperties(component); | 109 | Set<ConfigProperty> props = service.getProperties(component); |
110 | + | ||
111 | + if (props == null) { | ||
112 | + return; | ||
113 | + } | ||
114 | + | ||
110 | Optional<ConfigProperty> property = props.stream() | 115 | Optional<ConfigProperty> property = props.stream() |
111 | .filter(p -> p.name().equals(name)).findFirst(); | 116 | .filter(p -> p.name().equals(name)).findFirst(); |
112 | if (!property.isPresent()) { | 117 | if (!property.isPresent()) { | ... | ... |
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | package org.onosproject.cli.cfg; | 16 | package org.onosproject.cli.cfg; |
17 | 17 | ||
18 | import java.util.List; | 18 | import java.util.List; |
19 | +import java.util.Set; | ||
19 | import java.util.SortedSet; | 20 | import java.util.SortedSet; |
20 | 21 | ||
21 | import org.apache.felix.service.command.CommandSession; | 22 | import org.apache.felix.service.command.CommandSession; |
... | @@ -24,6 +25,7 @@ import org.apache.karaf.shell.console.Completer; | ... | @@ -24,6 +25,7 @@ import org.apache.karaf.shell.console.Completer; |
24 | import org.apache.karaf.shell.console.completer.ArgumentCompleter; | 25 | import org.apache.karaf.shell.console.completer.ArgumentCompleter; |
25 | import org.apache.karaf.shell.console.completer.StringsCompleter; | 26 | import org.apache.karaf.shell.console.completer.StringsCompleter; |
26 | import org.onosproject.cfg.ComponentConfigService; | 27 | import org.onosproject.cfg.ComponentConfigService; |
28 | +import org.onosproject.cfg.ConfigProperty; | ||
27 | import org.onosproject.cli.AbstractShellCommand; | 29 | import org.onosproject.cli.AbstractShellCommand; |
28 | 30 | ||
29 | /** | 31 | /** |
... | @@ -46,8 +48,11 @@ public class ComponentPropertyNameCompleter implements Completer { | ... | @@ -46,8 +48,11 @@ public class ComponentPropertyNameCompleter implements Completer { |
46 | AbstractShellCommand.get(ComponentConfigService.class); | 48 | AbstractShellCommand.get(ComponentConfigService.class); |
47 | 49 | ||
48 | SortedSet<String> strings = delegate.getStrings(); | 50 | SortedSet<String> strings = delegate.getStrings(); |
49 | - service.getProperties(componentName) | 51 | + Set<ConfigProperty> properties = |
50 | - .forEach(property -> strings.add(property.name())); | 52 | + service.getProperties(componentName); |
53 | + if (properties != null) { | ||
54 | + properties.forEach(property -> strings.add(property.name())); | ||
55 | + } | ||
51 | 56 | ||
52 | // Now let the completer do the work for figuring out what to offer. | 57 | // Now let the completer do the work for figuring out what to offer. |
53 | return delegate.complete(buffer, cursor, candidates); | 58 | return delegate.complete(buffer, cursor, candidates); | ... | ... |
-
Please register or login to post a comment