spring-projects / spring-projects/spring-boot
Include list of effective properties in environment endpoint's response
@philwebb is already working on this.
Since Jul 19, 2021.
- Dominant language
- Java
- Stars
- 81.5k
- Forks
- 42.7k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 65
Description
Currently, EnvironmentEndpoint shows where all of PropertySources are coming from including duplicated keys(overrides) if they are from different sources. (e.g.: one from application.yaml and same key from application-<profile>.yaml)
Usually, while troubleshooting or debugging, what people want to find out is the final value resolved by the Environment.(actual value resolved by @Value("x.y.z") etc.)
Current /env can serve the purpose, but may need to go through several hoops to get the correct answer if there are overrides.
Having final property key-values as part of EnvironmentEndpoint would give clear answer what key-values are used in application.
Such property sources considering override can be obtained like this:
Map<String, Object> map = new HashMap<>();
for (PropertySource<?> propertySource : ((ConfigurableEnvironment) this.environment).getPropertySources()) {
if (propertySource instanceof EnumerablePropertySource) {
for (String key : ((EnumerablePropertySource<?>) propertySource).getPropertyNames()) {
map.putIfAbsent(key, propertySource.getProperty(key));
}
}
}
// may sort the map with key...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.