question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What must the set of property names returned by Config#getPropertyNames() consist of?

See original GitHub issue

The javadocs for Config#getPropertyNames() say, in their entirety, and I see no other language related to this topic in the specification documents:

Return a collection of property names. Returns: the names of all configured keys of the underlying configuration.

It is hard to know what to make of this. Does this mean:

  1. The set of property names returned by Config#getPropertyNames() must consist only of the combination of the sets of property names returned by each ConfigSource present in the return value of Config#getConfigSources() and nothing else
  2. The set of property names returned by Config#getPropertyNames() may contain a subset of the combination of the sets of property names returned by each ConfigSource present in the return value of Config#getConfigSources()
  3. The set of property names returned by Config#getPropertyNames() can be anything the implementor wants, regardless of whether it is represented in part or in whole by any ConfigSource notionally contained by the Config …? 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 https://github.com/eclipse/microprofile-config/blob/828ee2fee4ccbef6701943bb96d7be187408fd63/tck/src/main/java/org/eclipse/microprofile/config/tck/ConfigProviderTest.java#L170-L183 which indirectly tests only that Config#getPropertyNames() must contain at least one key returned by the getPropertyNames() methods of the ConfigSource instances returned by getConfigSources() at the moment of the Config#getPropertyNames() call.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:29 (29 by maintainers)

github_iconTop GitHub Comments

1reaction
OndroMihcommented, Oct 20, 2019

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? ConfigSources can be mutable and new properties can be added dynamically, so thry don’t know the list of all their props at initialization. There are also good usecases to support completely dynamic sources that derive the value for some properties from their name, so a new property can be created as late as an app asks for 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.

1reaction
dmlloydcommented, Oct 18, 2019

I guess everyone did; no worries 😃

@Emily-Jiang I think this means that there is no further reason to prevent deprecation of ConfigSource#getProperties() for removal as @jmesnil has proposed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Object.getOwnPropertyNames() - JavaScript - MDN Web Docs
The Object.getOwnPropertyNames() method returns an array of all properties (including non-enumerable properties except for those which use Symbol) found ...
Read more >
How to customize property names and values with System. ...
To set the name of individual properties, use the [JsonPropertyName] attribute. Here's an example type to serialize and resulting JSON:.
Read more >
How can I access a JavaScript object which has spaces in ...
Use ECMAscripts "bracket notation": myTextOptions[ 'character names' ].kid;. You can use that notation either way, reading & writting.
Read more >
Configure or display instrument object properties
props = set(obj) returns all configurable properties and their possible values for ... You can use any combination of property name/property value pairs, ......
Read more >
Retrieving and setting properties of a business object
If you are using a property name in a business object type that is reserved by Business Automation Workflow, for example metadata ,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found