poco
poco copied to clipboard
ConfigurationView Searches Original Configuration
As documented by https://docs.pocoproject.org/current/Poco.Util.ConfigurationView.html#:~:text=If%20a%20property%20is%20not%20found%20in%20the%20view%2C%20it%20is%20searched%20in%20the%20original%20configuration.%20Given%20the%20above%20example%20configuration%2C%20the%20property%20named%20%22config.value1%22%20will%20still%20be%20found%20in%20the%20view and as implemented in https://github.com/pocoproject/poco/blob/poco-1.12.2-release/Util/src/ConfigurationView.cpp#L38, ConfigurationView's has*()
and get*()
functions will search outside of the ConfigurationView in the original configuration if the element being queried isn't present in the ConfigurationView.
Given a configuration with the following properties:
value1 = abc
value2 = def
sub.value3 = ghi
sub.value4 = jkl
If I create a ConfigurationView with the prefix sub
and then call has("value1")
on that view, the function will return true. I would expect it to return false because sub
does not have an element named value1
. Similarly, if I call getString("value1")
on that view it will return abc
instead of throwing a NotFoundException
.
While this behavior is documented and while I understand that it was implemented in order to support placeholder expansion, I believe it is unintuitive and often unwanted. As such, I would like to request that either one of the following two solutions be implemented.
- Change the current behavior so that the
has*()
andget*()
functions of ConfigurationView behave as one would intuitively expect them to behave, and find another means of continuing to support placeholder expansion. - Provide the ability to change the behavior of ConfigurationView via a setting in the ConfigurationView class, with the documented caveat that changing the behavior may break placeholder expansion.
Thank you.
This issue is stale because it has been open for 365 days with no activity.
Could someone please take a look at this issue? I believe it is still an issue that should be addressed. Thank you.
@austin-beer your best bet is to do it yourself and send a pull request; I will review it and merge if it is acceptable. Otherwise, I can't promise when will this be addressed
Okay @aleks-f. I won't have time to do that anytime soon, but thank you for responding and letting me know.
This issue is stale because it has been open for 365 days with no activity.
This issue was closed because it has been inactive for 60 days since being marked as stale.