Pierre De Rop created FELIX-5399:
------------------------------------
Summary: Unable to define default map or list config types
Key: FELIX-5399
URL: https://issues.apache.org/jira/browse/FELIX-5399
Project: Felix
Issue Type: Bug
Components: Dependency Manager
Affects Versions: org.apache.felix.dependencymanager-r8
Reporter: Pierre De Rop
Assignee: Pierre De Rop
Priority: Minor
Fix For: org.apache.felix.dependencymanager-r9
Assume you have a key in a given configuration dictionary which corresponds to
a map or a list.
For example:
{code}
map={key1=value1, key2=value2}
list=[a,b,c}
{code}
Now assume we have the corresponding configuration type, which defines default
values for the "map" or "list" keys:
{code}
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;
}
}
{code}
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.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)