-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What must the set of property names returned by Config#getPropertyNames() consist of? #431
Comments
@ljnelson It should be the following interpretation:
|
@Emily-Jiang Thanks very much. Shall I contribute a TCK test for this? |
@ljnelson please feel free to contribute. Thank you! |
Let's decide the real usage for this method as we plan to deprecate ConfigSource.getPropertiesNames and ConfigSource.getProperties. |
If you have a configuration which can detect invalid properties within a namespace, as we do in Quarkus, you need a way to know what configuration properties are present. The only way to do that in the MP Config API is by traversing all the property names of all the sources ( Given that there is a clear use case, it does not make sense to talk about deprecation. You'd need an overpoweringly significant reason to justify doing so. |
The question of deprecating |
@Emily-Jiang Please do not deprecate |
Given that there are use case for This would impact
The default implementation should be eventually removed and let the implementation of There is also a question about the relevance of Finally, if we keep both Shouldn't Config.getPropertyNames() return a |
@ljnelson can you please explain why you would need |
FWIW changing the return type doesn't have to be a breaking change. A second method could be added under a different name, with the original delegating to it, or a bridge could be introduced by introducing a non-public superinterface that only has the |
@dmlloyd What I was referring to was a comment that @Emily-Jiang made in an earlier issue where it was explained that what was intended was that If we are talking about removing both As mentioned previously please keep |
Ah I see. Well there is no such method as |
Guess I read carelessly; carry on. |
I guess everyone did; no worries :) @Emily-Jiang I think this means that there is no further reason to prevent deprecation of |
I see there's a usecase for ConfigSource.getPropertyNames in some cases, especially during initialization. However, we should ensure that the result is not constant and shouldn't be cached for a long time. I'm not sure this is ensured now, os it? If we deprecate getProperties and later remove it, we could change the default impl for getPropertyNames to return an empty set. This would indicate that it's OK to return an empty set of properties and still provide values later. Expensive config sources could decide to return an empty or incomplete set of property names and still work. Even if we leave getProperties, we can provide a default impl that returns an empty set. I would also consider how calling getPropertyNames/getProperties can slow down the app. If we allow configsources to return an empty/incomplete set of props and still provide more values later, that might solve this problem too. |
These methods are very useful for tooling. For example the Payara administration console uses these methods to display all known properties in some config sources for runtime configuration. I don't believe any of these methods should be deprecated. |
No this is not ensured. The set should at least be safe to access indefinitely though, and I don't think there's any reason not to specify that it must be thread safe also. But then, there isn't really any reasonable way to put an upper bound on how long users may cache it. To me the simplest implementation in the presence of mutable configuration (discussed in a different topic) will always be a snapshot as it satisfies all the basic requirements here.
Good idea!
I agree we definitely should explicitly allow |
@smillidge is there a use case in Payara for |
Yes if you want to display all the values getProperties is more efficient than the iteration. However in our case the number of properties is likely small. |
Understood, so using the Maybe we can find a middle ground between having to support a full, random-access |
Signed-off-by: Emily Jiang <emijiang6@googlemail.com>
…hanges #431 - undo this change as it has binary incompatible changes
Back to drawing board: |
I've done some javadoc update under #333 . Let's revisit this in Config 2.0 release in June to properly fix this. |
I'll redo the PR I did last time. |
Signed-off-by: Emily Jiang <emijiang6@googlemail.com>
I believe this issue can be closed. Please object in the next couple of days if you think otherwise. |
May I request a one sentence summary of the resolution at the bottom of this issue before it is closed? I am still not sure what the final outcome is, even with #534 being merged. Are there requirements or restrictions on the elements that can be returned in the |
I do think this needs a little more clarification. I'll work up a more specific PR. |
#538 contains my attempt to clarify the thread safety requirements. |
The javadocs for
Config#getPropertyNames()
say, in their entirety, and I see no other language related to this topic in the specification documents:It is hard to know what to make of this. Does this mean:
Config#getPropertyNames()
must consist only of the combination of the sets of property names returned by eachConfigSource
present in the return value ofConfig#getConfigSources()
and nothing elseConfig#getPropertyNames()
may contain a subset of the combination of the sets of property names returned by eachConfigSource
present in the return value ofConfig#getConfigSources()
Config#getPropertyNames()
can be anything the implementor wants, regardless of whether it is represented in part or in whole by anyConfigSource
notionally contained by theConfig
…? It must be one of these. The specification does not say, and there is no TCK test.
I am assuming that (1) is the proper answer (modulo any information related to #370). However, given that the specification says nothing and there is no TCK1, (3) is the de facto answer at the moment.
If (1) is the proper answer, should a TCK test exist for this?
If (1) is not the proper answer, why does this method exist?
1 There is
microprofile-config/tck/src/main/java/org/eclipse/microprofile/config/tck/ConfigProviderTest.java
Lines 170 to 183 in 828ee2f
Config#getPropertyNames()
must contain at least one key returned by thegetPropertyNames()
methods of theConfigSource
instances returned bygetConfigSources()
at the moment of theConfig#getPropertyNames()
call.The text was updated successfully, but these errors were encountered: