You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have recently created a custom EnvironmentPostProcessor that added a new property source into the Environment. The property source I added was a SystemEnvironmentPropertySource. Everything was seemingly working as expected but some of the relaxed binding rules (described here) weren't being applied as expected.
After much debugging and searching I came across this stackoverflow answer that explains that to ensure the environment variable relaxed binding rules are applied correctly to custom property sources, the property source name has to end with "-systemEnvironment". I assumed (wrongly) that the binding rules would be determined by the property source type, not an arbitrary suffix on the name.
I did some further digging and could not finding any documentation explaining this. Could we add something into the docs to explain this specific use case?
The text was updated successfully, but these errors were encountered:
Thanks for the suggestion. Given that SystemEnvironmentPropertySource is documented as being a "specialization of MapPropertySource designed for use with system environment variables", I'd be interested to know what the use case is for a custom property source of this type. To avoid bloating the reference documentation too much, we have to make decisions about what we do and don't document and on the face off it, this seems like quite a niche need.
I have environment variables that are encrypted. They typically contain passwords, secrets etc. I want to decrypt them in our spring boot apps in a common way before the Environment is fully loaded. As a result using an EnvironmentPostProcessor and adding a new property source in the environment was the direction that was taken to solve this.
Its similar to the suggestion here in the reference docs.
Since the source of the secrets are env vars, after decrypting them I create a new SystemEnvironmentPropertySource that contains the decrypted env vars and this is added to the property sources at a higher precedence than the default SystemEnvironmentPropertySource.
Its a replacement for a process that was previously done in bash, in my docker container before starting the spring boot app.
wilkinsona
changed the title
Improve documentation on registering custom system environment property source via environment post processor
Document when environment variable property mapping applies
Aug 19, 2024
I have recently created a custom
EnvironmentPostProcessor
that added a new property source into theEnvironment
. The property source I added was aSystemEnvironmentPropertySource
. Everything was seemingly working as expected but some of the relaxed binding rules (described here) weren't being applied as expected.After much debugging and searching I came across this stackoverflow answer that explains that to ensure the environment variable relaxed binding rules are applied correctly to custom property sources, the property source name has to end with "-systemEnvironment". I assumed (wrongly) that the binding rules would be determined by the property source type, not an arbitrary suffix on the name.
I did some further digging and could not finding any documentation explaining this. Could we add something into the docs to explain this specific use case?
The text was updated successfully, but these errors were encountered: