-
Notifications
You must be signed in to change notification settings - Fork 40.9k
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
Short circuit checking of source already covered by ConfigurationPropertySources #17400
Comments
I'm sorry but I don't understand what you're reporting. If you think you've found a bug can you please provide a sample application that shows the problem. |
@philwebb I want to know why to call method So when invoking
I just want to express that because |
I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference. |
@brucelwl The issue tracker isn't the place for these kinds of discussions as It adds a lot of noise for everyone subscribed. We prefer to keep it for bugs or feature requests. Questions like this can be asked at stackoverflow.com or gitter.im. |
@philwebb I'm not just asking why, it's also a logical error, because it leads to a redundant loop traversal |
@brucelwl I don't believe there's a logical error, but if you can provide a sample that shows what you mean I'm happy to take a look. The |
Please take a look at my demo, https://github.com/brucelwl/demo But we can see that the first PropertySource When using a loop to look up a key-value pair from each propertySource, if it can't be found from the first PropertySource |
@brucelwl Thanks for the sample, I see what you're getting at now. The checking of subsequent property sources is only short circuited if the value is found. If the value is not found then we search the source again. Unfortunately it's not that easy to fix this one. We might be able to improve things if we can change |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Excuse me, have you fixed it? |
No, not yet. This issue is still open and currently assigned to the general backlog. |
This comment has been minimized.
This comment has been minimized.
Did you finally fix it with cache? |
@dngzs The issue is still open |
(edited with updated description)
Currently
ConfigurationPropertySources
is added to the environment so that relaxed property resolution can work directly. TheConfigurationPropertySources
acts as a facade over the existing property sources.When making a call such as
environment.getProperty("test")
, if the property is found thenConfigurationPropertySources
will return the result. If, however, the property is not found byConfigurationPropertySources
thePropertySourcesPropertyResolver
continues to check all subsequent sources. This is a little inefficient for any source that has already been check viaConfigurationPropertySources
.Original report:
getProperty(String key, Class<T> targetValueType, boolean resolveNestedPlaceholders)
inorg.springframework.core.env.PropertySourcesPropertyResolver
traverses allPropertySources
, so why useConfigurationPropertySourcesPropertySource
to wrap thesePropertySources
collections, andConfigurationPropertySourcesPropertySource
is traversed as well? So it seems that afterConfigurationPropertySourcesPropertySource
has been traversed, it seems meaningless that the remaining elements are traversed, becauseConfigurationPropertySourcesPropertySource
has been checkedThe text was updated successfully, but these errors were encountered: