[ONOS-6354] CFG values and applied values are mismatching while trying to set a property with an invalid value
Change-Id: Id2e343c61419441d0b9554df3291b35829e850ab
(cherry picked from commit c86d95f969864664beb3948bc5ff2c455e372393)
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 64f6b50..0a85ae0 100644
--- a/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java
@@ -72,20 +72,24 @@
@Override
protected void execute() {
service = get(ComponentConfigService.class);
- if (isNullOrEmpty(command)) {
- listComponents();
- } else if (command.equals(GET) && isNullOrEmpty(component)) {
- listAllComponentsProperties();
- } else if (command.equals(GET) && isNullOrEmpty(name)) {
- listComponentProperties(component);
- } else if (command.equals(GET)) {
- listComponentProperty(component, name);
- } else if (command.equals(SET) && isNullOrEmpty(value)) {
- service.unsetProperty(component, name);
- } else if (command.equals(SET)) {
- service.setProperty(component, name, value);
- } else {
- error("Illegal usage");
+ try {
+ if (isNullOrEmpty(command)) {
+ listComponents();
+ } else if (command.equals(GET) && isNullOrEmpty(component)) {
+ listAllComponentsProperties();
+ } else if (command.equals(GET) && isNullOrEmpty(name)) {
+ listComponentProperties(component);
+ } else if (command.equals(GET)) {
+ listComponentProperty(component, name);
+ } else if (command.equals(SET) && isNullOrEmpty(value)) {
+ service.unsetProperty(component, name);
+ } else if (command.equals(SET)) {
+ service.setProperty(component, name, value);
+ } else {
+ error("Illegal usage");
+ }
+ } catch (IllegalArgumentException e) {
+ error(e.getMessage());
}
}