[jboss-jira] [JBoss JIRA] (WFWIP-314) [EAP7-1386] additional ConfigSources are always initialized

Ronald Sigal (Jira) issues at jboss.org
Sat Apr 25 16:13:00 EDT 2020


    [ https://issues.redhat.com/browse/WFWIP-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14058147#comment-14058147 ] 

Ronald Sigal commented on WFWIP-314:
------------------------------------

Hi [~pkremens],

The way MicroProfile works is that it looks for a service loader file named META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource and loads the contents. Currently, the file in resteasy-jaxrs is
{code}
org.jboss.resteasy.microprofile.config.ServletConfigSource
org.jboss.resteasy.microprofile.config.FilterConfigSource
org.jboss.resteasy.microprofile.config.ServletContextConfigSource
{code}
If there are no servlet-context properties, for example, that ConfigSource will be empty. 

Note that if the Config jars are absent, then the ConfigSources won't get loaded. See https://issues.redhat.com/browse/WFWIP-313 for more about that.

-Ron

> [EAP7-1386] additional ConfigSources are always initialized
> -----------------------------------------------------------
>
>                 Key: WFWIP-314
>                 URL: https://issues.redhat.com/browse/WFWIP-314
>             Project: WildFly WIP
>          Issue Type: Quality Risk
>            Reporter: Petr Kremensky
>            Assignee: Ronald Sigal
>            Priority: Minor
>
> I've noticed that three additional config sources provided by EAP7-1386 are always registered among config sources, even they are empty. I'll probably reject this one myself soon :) as I still have to look into the implementation of SPI for mp config, so I can assume that this is just out of box behaviour we have no control over.
> Test with a simple servlet from [helloworld|https://github.com/wildfly/quickstart/tree/master/helloworld] quickstart with following addition:
> {code:java}
>   ConfigProvider.getConfig().getConfigSources().forEach(configSource -> {
>      System.out.println("=================================");
>      System.out.println(configSource.getName());
>      System.out.println(configSource.getOrdinal());
>      System.out.println("Property names: " + configSource.getPropertyNames().stream().collect(Collectors.joining(", ")));
>   });
> {code}
> output:
> {noformat}
> =================================
> SysPropConfigSource
> 400
> [Standalone], awt.toolkit, ...
> =================================
> EnvConfigSource
> 300
> PATH, INVOCATION_ID, ...
> =================================
> null:null:ServletConfigSource
> 60
> =================================
> null:null:FilterConfigSource
> 50
> =================================
> null:ServletContextConfigSource
> 40
> {noformat}
> Notice that {{PropertiesConfigSource}} is missing there as none was put to classpath. On the other hand {PropertiesConfigSource} is present once added to classpath, even it is empty.
> {noformat}
> ...
> =================================
> PropertiesConfigSource[source=vfs:/content/helloworld.war/WEB-INF/classes/META-INF/microprofile-config.properties]
> 100
> Property names:
> =================================
> null:null:ServletConfigSource
> 60
> Property names:
> =================================
> null:null:FilterConfigSource
> 50
> Property names:
> =================================
> null:ServletContextConfigSource
> 40
> Property names:
> {noformat}
> As stated before, I'd probably close this one myself once I'll take deeper look into it.



--
This message was sent by Atlassian Jira
(v7.13.8#713008)


More information about the jboss-jira mailing list