Jon Hall

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
...@@ -95,7 +95,9 @@ public class ComponentConfigCommand extends AbstractShellCommand { ...@@ -95,7 +95,9 @@ public class ComponentConfigCommand extends AbstractShellCommand {
95 private void listComponentProperties(String component) { 95 private void listComponentProperties(String component) {
96 Set<ConfigProperty> props = service.getProperties(component); 96 Set<ConfigProperty> props = service.getProperties(component);
97 print("%s", component); 97 print("%s", component);
98 - if (shortOnly) { 98 + if (props == null) {
99 + print("No properties for component " + component + " found");
100 + } else if (shortOnly) {
99 props.forEach(p -> print(SHORT_FMT, p.name(), p.value())); 101 props.forEach(p -> print(SHORT_FMT, p.name(), p.value()));
100 } else { 102 } else {
101 props.forEach(p -> print(FMT, p.name(), p.type().toString().toLowerCase(), 103 props.forEach(p -> print(FMT, p.name(), p.type().toString().toLowerCase(),
...@@ -108,7 +110,7 @@ public class ComponentConfigCommand extends AbstractShellCommand { ...@@ -108,7 +110,7 @@ public class ComponentConfigCommand extends AbstractShellCommand {
108 Optional<ConfigProperty> property = props.stream() 110 Optional<ConfigProperty> property = props.stream()
109 .filter(p -> p.name().equals(name)).findFirst(); 111 .filter(p -> p.name().equals(name)).findFirst();
110 if (!property.isPresent()) { 112 if (!property.isPresent()) {
111 - System.err.println("Property " + name + " for component " + component + " not found"); 113 + print("Property " + name + " for component " + component + " not found");
112 return; 114 return;
113 } 115 }
114 ConfigProperty p = property.get(); 116 ConfigProperty p = property.get();
......
...@@ -64,9 +64,9 @@ public class CoreManager implements CoreService { ...@@ -64,9 +64,9 @@ public class CoreManager implements CoreService {
64 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 64 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
65 protected ComponentConfigService cfgService; 65 protected ComponentConfigService cfgService;
66 66
67 - @Property(name = "sharedThreadPoolSize", intValue = SharedExecutors.DEFAULT_POOL_SIZE, 67 + @Property(name = "sharedThreadPoolSize", intValue = 30,
68 label = "Configure shared pool maximum size ") 68 label = "Configure shared pool maximum size ")
69 - private int sharedThreadPoolSize = SharedExecutors.DEFAULT_POOL_SIZE; 69 + private int sharedThreadPoolSize = 30;
70 70
71 @Activate 71 @Activate
72 public void activate() { 72 public void activate() {
......