Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-10854

Default value defined on injection point of List and Set fields is not taken into account

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 20.0.0.Beta1
    • None
    • MP Config
    • None

      Assume we define a following injection points:

              @Inject
              @ConfigProperty(name = "myPets", defaultValue = "horse,monkey")
              private String[] myArrayPets;
      
              @Inject
              @ConfigProperty(name = "myPets", defaultValue = "cat,lama")
              private List<String> myListPets;
      
              @Inject
              @ConfigProperty(name = "myPets", defaultValue = "dog,mouse")
              private Set<String> mySetPets;
      

      Passing a -DmyPets=snake,ox property work as expected:

      myArrayPets : [snake,ox]
      myListPets  : [snake,ox]
      mySetPets   : [snake,ox]
      

      but trying to use the defults I get:

      myArrayPets : [horse,monkey]
      myListPets  : <empty list>
      mySetPets   : <empty set>
      

      defaults are not applied to List and Set fields, no exception is thrown.

      Another inconsistency between Array and Set+List I run into is behaviour on missing property (myPets is not set):
      Array

              @Inject
              @ConfigProperty(name = "myPets")
              private String[] myArrayPets;
      >>>
      08:34:05,178 ERROR [stderr] (MSC service thread 1-2) org.jboss.weld.exceptions.DeploymentException: Error while validating Configuration
      08:34:05,178 ERROR [stderr] (MSC service thread 1-2) No Config Value exists for myPets
      
      myArrayPets : [org.eclipse.microprofile.config.configproperty.unconfigureddvalue]
      

      Set, List

              @Inject
              @ConfigProperty(name = "myPets")
              private List<String> myListPets;
      
              @Inject
              @ConfigProperty(name = "myPets")
              private Set<String> mySetPets;
      >>>
      no errors
      
      myListPets  : <empty list>
      mySetPets   : <empty set>
      

      https://microprofile.io/project/eclipse/microprofile-config/spec/src/main/asciidoc/converters.asciidoc

            rhn-cservice-bbaranow Bartosz Baranowski
            pkremens@redhat.com Petr Kremensky (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: