Avoid NPE in cfg command
- Avoid NPE when a component has no configurable property or doesn't exist
- Specificly use a numeric value for SharedExecutors.DEFAULT_POOL_SIZE so
the value appears in cfg command
- Also use print instead of system.err since it is being redirected
away from the console
Change-Id: Ib73016b1a9282493f0c5c8c217dd33292eac4ba4
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 953f27c..b1e5150 100644
--- a/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java
@@ -95,7 +95,9 @@
private void listComponentProperties(String component) {
Set<ConfigProperty> props = service.getProperties(component);
print("%s", component);
- if (shortOnly) {
+ if (props == null) {
+ print("No properties for component " + component + " found");
+ } else if (shortOnly) {
props.forEach(p -> print(SHORT_FMT, p.name(), p.value()));
} else {
props.forEach(p -> print(FMT, p.name(), p.type().toString().toLowerCase(),
@@ -108,7 +110,7 @@
Optional<ConfigProperty> property = props.stream()
.filter(p -> p.name().equals(name)).findFirst();
if (!property.isPresent()) {
- System.err.println("Property " + name + " for component " + component + " not found");
+ print("Property " + name + " for component " + component + " not found");
return;
}
ConfigProperty p = property.get();