Throw exceptions when registered properties that do not exist
Change-Id: I527c36b9be5c44ab4072218b3d18008c0ae486b6
Showing
1 changed file
with
13 additions
and
0 deletions
... | @@ -61,6 +61,9 @@ public class ComponentConfigManager implements ComponentConfigService { | ... | @@ -61,6 +61,9 @@ public class ComponentConfigManager implements ComponentConfigService { |
61 | 61 | ||
62 | private static final String COMPONENT_NULL = "Component name cannot be null"; | 62 | private static final String COMPONENT_NULL = "Component name cannot be null"; |
63 | private static final String PROPERTY_NULL = "Property name cannot be null"; | 63 | private static final String PROPERTY_NULL = "Property name cannot be null"; |
64 | + private static final String COMPONENT_MISSING = "Component %s is not registered"; | ||
65 | + private static final String PROPERTY_MISSING = "Property %s does not exist for %s"; | ||
66 | + | ||
64 | 67 | ||
65 | //Symbolic constants for use with the accumulator | 68 | //Symbolic constants for use with the accumulator |
66 | private static final int MAX_ITEMS = 100; | 69 | private static final int MAX_ITEMS = 100; |
... | @@ -160,6 +163,11 @@ public class ComponentConfigManager implements ComponentConfigService { | ... | @@ -160,6 +163,11 @@ public class ComponentConfigManager implements ComponentConfigService { |
160 | 163 | ||
161 | checkNotNull(componentName, COMPONENT_NULL); | 164 | checkNotNull(componentName, COMPONENT_NULL); |
162 | checkNotNull(name, PROPERTY_NULL); | 165 | checkNotNull(name, PROPERTY_NULL); |
166 | + | ||
167 | + checkArgument(properties.containsKey(componentName), | ||
168 | + COMPONENT_MISSING, componentName); | ||
169 | + checkArgument(properties.get(componentName).containsKey(name), | ||
170 | + PROPERTY_MISSING, name, componentName); | ||
163 | store.setProperty(componentName, name, value); | 171 | store.setProperty(componentName, name, value); |
164 | } | 172 | } |
165 | 173 | ||
... | @@ -169,6 +177,11 @@ public class ComponentConfigManager implements ComponentConfigService { | ... | @@ -169,6 +177,11 @@ public class ComponentConfigManager implements ComponentConfigService { |
169 | 177 | ||
170 | checkNotNull(componentName, COMPONENT_NULL); | 178 | checkNotNull(componentName, COMPONENT_NULL); |
171 | checkNotNull(name, PROPERTY_NULL); | 179 | checkNotNull(name, PROPERTY_NULL); |
180 | + | ||
181 | + checkArgument(properties.containsKey(componentName), | ||
182 | + COMPONENT_MISSING, componentName); | ||
183 | + checkArgument(properties.get(componentName).containsKey(name), | ||
184 | + PROPERTY_MISSING, name, componentName); | ||
172 | store.unsetProperty(componentName, name); | 185 | store.unsetProperty(componentName, name); |
173 | } | 186 | } |
174 | 187 | ... | ... |
-
Please register or login to post a comment