[jboss-jira] [JBoss JIRA] (WFWIP-55) Default value defined on injection point of List and Set fields is not taken into account

Petr Kremensky (JIRA) issues at jboss.org
Tue Jul 17 02:45:04 EDT 2018


Petr Kremensky created WFWIP-55:
-----------------------------------

             Summary: Default value defined on injection point of List and Set fields is not taken into account
                 Key: WFWIP-55
                 URL: https://issues.jboss.org/browse/WFWIP-55
             Project: WildFly WIP
          Issue Type: Bug
          Components: MP Config
            Reporter: Petr Kremensky
            Assignee: Jeff Mesnil


Assume we define a following injection points:
{code:java}
        @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;
{code}
Passing a -DmyPets=snake,ox property work as expected:
{noformat}
myArrayPets : [snake,ox]
myListPets  : [snake,ox]
mySetPets   : [snake,ox]
{noformat}
but trying to use the defults I get:
{noformat}
myArrayPets : [horse,monkey]
myListPets  : <empty list>
mySetPets   : <empty set>
{noformat}
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*
{code:java}
        @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]
{code}
*Set, List*
{code:java}
        @Inject
        @ConfigProperty(name = "myPets")
        private List<String> myListPets;

        @Inject
        @ConfigProperty(name = "myPets")
        private Set<String> mySetPets;
>>>
no errors

myListPets  : <empty list>
mySetPets   : <empty set>
{code}

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



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)


More information about the jboss-jira mailing list