Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
org.apache.felix.dependencymanager-r8
-
None
Description
Assume you have a key in a given configuration dictionary which corresponds to a map or a list.
For example:
map={key1=value1, key2=value2} list=[a,b,c}
Now assume we have the corresponding configuration type, which defines default values for the "map" or "list" keys:
public interface ConfigType { public default List<String> getList() { return Arrays.asList("default1", "default2"); } public default SortedMap<String, String> getMap() { SortedMap<String, String> defaultMap = new TreeMap<>(); defaultMap.put("key1", "default1"); defaultMap.put("key2", "default2"); return defaultMap; } }
Now, assume also that:
- you use an optional configurationdependency and the configuration is currently unavailable
- or the configuration is currently available (whatever the configuration dependency is optional or required), but there is currently no values for "map" or "list" keys
Then the problem is that the default map or list values declared in the ConfigType interface are not used as default values, but instead when you access to the "map" or "list" configuration keys, then you get an implicit empty map or an empty list (instead of the defaults values defined in the configuration type)
See org.apache.felix.dm.itest.api.DefaultListConfigType.java and org.apache.felix.dm.itest.api.DefaultMapConfigType, which reproduce the issue.