Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-5400

Can't override default configuration type list value using an empty list

    XMLWordPrintableJSON

Details

    Description

      Assume you are using the following configuration type:

          public interface MyConfig {
              public default List<String> getList() { 
              	return Arrays.asList("a", "b");
              }        
          }
      

      So, you can then declare the following values in the actual configuration dictionary for the "list" key:

      list=[a,b]
      
      or
      
      list.0=a
      list.1=b
      

      But assuming that you now want to register in config admin a configuration dictionary with an empty list (you really want an empty list []): then it is not currently possible, because if you don't declare any values for the "list" key, then the default value of the configuration type will be returned (see FELIX5399).

      And if you declare the following value for the "list" key:

      list=[]

      then it does not work too (an empty list won't be returned) because the "toCollection" method in the Configurable.java class calls:

      Arrays.asList(str.split("\\s*,\\s*"))
      

      which then returns an array of size=1, instead of returning an array of zero size.

      Attachments

        Activity

          People

            pderop Pierre De Rop
            pderop Pierre De Rop
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: