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

Jeff Mesnil (JIRA) issues at jboss.org
Tue Jul 17 06:07:00 EDT 2018


    [ https://issues.jboss.org/browse/WFWIP-55?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13606076#comment-13606076 ] 

Jeff Mesnil commented on WFWIP-55:
----------------------------------

I have opened https://github.com/eclipse/microprofile-config/issues/376 to clarify the behaviour of injected collection and array without configured and default values.

Note that regardless of the behaviour, it must be consistent between array and collections (which is not the case currently).

> 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