-
Jun 19th, 2009, 07:10 AM
#1
Trimming values with property configurers
I have a setup that uses external configuration files together with PropertyPlaceholderConfigurer and PropertyOverrideConfigurer, which works great.
However, I've had some trouble with putting spaces after property values several times - this breaks up some of my functionality. I mean things like "false<space>" which I've seen interpreted as "true", or "353<space>" which throws a NumberFormatException when being parsed into a number. For sensitive string properties, I can trim spaces programmatically, however for values which end up being parsed out of my reach into booleans or numbers this is a problem.
Any ideas on the simplest way to have the two property configurers trim spaces by default?
-
Jun 19th, 2009, 07:40 AM
#2
I don't know an out of the box solution here. However, you could create own subclasses of PropertyPlaceholderConfigurer/PropertyOverrideConfigurer and overwrite the method convertPropertyValue().
In the overwritten method you could then return a trimmed version of the passed-in string, which should do the trick.
Besides that you might consider to file a feature request in jira for making trimming configurable. I think that might be a useful feature, too.
Regards,
Andreas
-
Jun 19th, 2009, 08:49 AM
#3
Thank you for the swift reply! I followed your advice and re-implemented the convertPropertyValue() method and all seems to work well now.
I've also added an improvement request in the spring jira at http://jira.springsource.org/browse/SPR-5839
-
Feb 17th, 2011, 05:32 AM
#4
Trimming values with property configurers
I faced the same situation, but in my case I declared the property systemPropertiesModeName=SYSTEM_PROPERTIES_MODE_OVERRIDE in my PropertyPlaceholderConfigurer.
So I had to override the resolveSystemProperty method in order to trim system properties as well.
I hope this to be useful for somebody.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules