Results 1 to 4 of 4

Thread: Trimming values with property configurers

  1. #1

    Default 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?

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    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

  3. #3

    Default

    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

  4. #4
    Join Date
    Oct 2010
    Location
    Murcia, Spain
    Posts
    1

    Default 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
  •