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
{{ message }}
Repository navigation
Properties read from traditional application.properties files are not trimmed #4106
The property values read from traditional application.properties configuration files are not trimmed. This can lead to undesired/strange behaviours at runtime:
@ConditionalOnProperty annotation perform a simple equals between the expected and received value (without type conversion). A property value set to 'true ' (notice the space at the end) is likely to fail the condition
developers must/should trim the injected string values themselves
Not trimming values out of properties files is error prone (you can't blame a user if they forgot a blank at the end of the line - they don't see it). It may be acceptable for XML files however: value is between start/end markers so the blank is visible.
Proposition is to update the PropertiesPropertySourceLoader so it automatically trims values read from .properties files.
changed the title [-]Property values read from traditional application.properties files are not trimmed[/-][+]Properties read from traditional application.properties files are not trimmed[/+]on Oct 8, 2015
We've discussed this and decided that there's no way that we can safely trim properties as we have no way of knowing whether or not any trailing whitespace was intentional.
If you have a problem where developers are leaving trailing whitespace in a properties file and you know that you never want such trailing whitespace, I would recommend configuring your editor to remove it automatically.
At least add a warning!
This ran us crazy trying to figure out why some people saw an error and others didn't, only to find out it was because of-what most editors show as-invisible characters!
Activity
[-]Property values read from traditional application.properties files are not trimmed[/-][+]Properties read from traditional application.properties files are not trimmed[/+]wilkinsona commentedon Jan 20, 2016
We've discussed this and decided that there's no way that we can safely trim properties as we have no way of knowing whether or not any trailing whitespace was intentional.
If you have a problem where developers are leaving trailing whitespace in a properties file and you know that you never want such trailing whitespace, I would recommend configuring your editor to remove it automatically.
lunarcloud commentedon Feb 5, 2018
At least add a warning!
This ran us crazy trying to figure out why some people saw an error and others didn't, only to find out it was because of-what most editors show as-invisible characters!
lunarcloud commentedon Feb 5, 2018
Nevermind. My issue was with the logging properties reader, not the generic property reading.