Throw exceptions when registered properties that do not exist
Change-Id: I527c36b9be5c44ab4072218b3d18008c0ae486b6
diff --git a/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java b/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java
index 1933ee5..5d5d73f 100644
--- a/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java
+++ b/core/net/src/main/java/org/onosproject/cfg/impl/ComponentConfigManager.java
@@ -61,6 +61,9 @@
private static final String COMPONENT_NULL = "Component name cannot be null";
private static final String PROPERTY_NULL = "Property name cannot be null";
+ private static final String COMPONENT_MISSING = "Component %s is not registered";
+ private static final String PROPERTY_MISSING = "Property %s does not exist for %s";
+
//Symbolic constants for use with the accumulator
private static final int MAX_ITEMS = 100;
@@ -160,6 +163,11 @@
checkNotNull(componentName, COMPONENT_NULL);
checkNotNull(name, PROPERTY_NULL);
+
+ checkArgument(properties.containsKey(componentName),
+ COMPONENT_MISSING, componentName);
+ checkArgument(properties.get(componentName).containsKey(name),
+ PROPERTY_MISSING, name, componentName);
store.setProperty(componentName, name, value);
}
@@ -169,6 +177,11 @@
checkNotNull(componentName, COMPONENT_NULL);
checkNotNull(name, PROPERTY_NULL);
+
+ checkArgument(properties.containsKey(componentName),
+ COMPONENT_MISSING, componentName);
+ checkArgument(properties.get(componentName).containsKey(name),
+ PROPERTY_MISSING, name, componentName);
store.unsetProperty(componentName, name);
}