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
The following application running under Spring Boot 1.5.14 outputs
:1
abc :6
but after upgrading to 2.0.0 outputs
:0
abc:3
Is that intended behavior? The comment on #4106 by @wilkinsona suggests that properties should not be trimmed. But discussion under #11029 suggests that there were in fact some changes related to trimming of collection properties.
I used a "separator" property in an application that does CSV parsing just like in the example below. The separator is a tab and with 2.0 it seems I have no way to specify that via properties.
This discussion in #11029 specifically relates to binding comma-separated strings to collections and arrays. E.g. you can have properties some.value=Fred, Velma,Daphne bound to List<String> and it will contain ["Fred", "Velma", "Daphne"]. That change was driven mainly by the StringToCollectionConverter in Spring Framework which trims elements.
I think the trimming of other values is more problematic unless we can provide a sensible way to escape things. From a quick glance, it's not entirely clear which part of the Spring Boot code is actually trimming those values. Nothing in org.springframework.boot.context.properties.bind seems to be doing it. Perhaps it's related to our new property loading. We'll need to dig a bit deeper.
This is a bug in OriginTrackedPropertiesLoader. If I add "withspace= with " to the test-properties.properties used by OriginTrackedPropertiesLoaderTests then compareToJavaProperties fails.
It's specified in the javadoc for Properties.load where it says:
Any white space after the key is skipped; if the first non-white space character after the key is '=' or ':', then it is ignored and any white space characters after it are also skipped. All remaining characters on the line become part of the associated element string
Activity
philwebb commentedon Jun 30, 2018
This discussion in #11029 specifically relates to binding comma-separated strings to collections and arrays. E.g. you can have properties
some.value=Fred, Velma,Daphnebound toList<String>and it will contain["Fred", "Velma", "Daphne"]. That change was driven mainly by theStringToCollectionConverterin Spring Framework which trims elements.I think the trimming of other values is more problematic unless we can provide a sensible way to escape things. From a quick glance, it's not entirely clear which part of the Spring Boot code is actually trimming those values. Nothing in
org.springframework.boot.context.properties.bindseems to be doing it. Perhaps it's related to our new property loading. We'll need to dig a bit deeper.philwebb commentedon Jun 30, 2018
This is a bug in
OriginTrackedPropertiesLoader. If I add "withspace= with " to thetest-properties.propertiesused byOriginTrackedPropertiesLoaderTeststhencompareToJavaPropertiesfails.jacekkruger commentedon Jul 3, 2018
It should work just like before now but I'm also curious why is the leading whitespace trimmed? Haven't found that documented anywhere.
wilkinsona commentedon Jul 3, 2018
It's specified in the javadoc for
Properties.loadwhere it says: