MP Config 1.4 question regarding ConfigProvider

20 views
Skip to first unread message

Laird Nelson

unread,
May 27, 2020, 9:37:14 PM5/27/20
to Eclipse MicroProfile
Hello; I hope everyone is safe and well.  Remember that you're not working in a pandemic, you're in a pandemic trying to get some work done.  There's a difference!

I had a question about the ConfigProvider class, specifically its getConfig() method and its reentrancy, referencing MicroProfile Config 1.4.  (I'm asking as a user, not as a committer.)

Suppose someone has called ConfigProvider.getConfig().  During that call, while the Config in question is being provisioned, my (custom) ConfigSource is found (for the first time), and, while that call is still happening, is queried for some property.  (Many times this property is something like config_ordinal or something else my ConfigSource has no opinion on.)  This is all expected and fine.

Now, if my ConfigSource calls ConfigProvider.getConfig() at that point (carefully excluding itself via state flags or some other scenario so as to avoid subsequent infinite loops etc.) so as to get a different configuration property value, what must happen with respect to this invocation?  Or is it undefined?  (Please ignore whether this is a good or a bad idea; I'm interested in the specification constraints.)

Specifically, must the Config returned by the second call—while the Config is still being provisioned—be the very same Config that is in the process of being provisioned?


"A factory method ConfigProvider#getConfig() to create a Config object based on automatically picked up ConfigSources of the Application identified by the current Thread Context ClassLoader classpath [sic]. The default and the auto discovered Converters will be gathered to form a configuration. Subsequent calls to this method for a certain Application will return the same Config instance."

Must this last sentence also apply while the Config itself is being provisioned?  It sounds like it to me but I quite likely have misunderstood.  Or is this behavior undefined?

Thanks,
Best,
Laird

Emily Jiang

unread,
May 28, 2020, 10:14:52 AM5/28/20
to Eclipse MicroProfile

Hi Laird,

We have a dedicated mailing list for MP Config. In the future, you can post a dedicated config query there.

To give you a short answer as per your use case, the behaviour is undefined by the spec. The best practices is not to use config in your custom config source as the Config object would be built after all configsources are loaded and consulted. However, there is one issue in MP Config with some proposal to allow the query of lower ordinal config properties. It is not being worked on as yet.

In summary, the reference of config in configsource is unsupported from the spec pespective. Implementations may decide to support it of course.

Thanks
Emily

Laird Nelson

unread,
May 28, 2020, 1:52:40 PM5/28/20
to Eclipse MicroProfile
On Thursday, May 28, 2020 at 7:14:52 AM UTC-7, Emily Jiang wrote:
To give you a short answer as per your use case, the behaviour is undefined by the spec.

Perfect; thank you!

Best,
Laird 
Reply all
Reply to author
Forward
0 new messages