Skip to content

Properties getting trimmed since 2.0 #13602

Closed
@jacekkruger

Description

@jacekkruger

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.

Application.java:

@SpringBootApplication
@ConfigurationProperties("application")
public class Application {

    private String separator;

    private String string;

    public String getSeparator() {
        return separator;
    }

    public void setSeparator(String separator) {
        this.separator = separator;
    }

    public String getString() {
        return string;
    }

    public void setString(String string) {
        this.string = string;
    }

    @PostConstruct
    void postConstruct() {
        System.out.println(separator + ":" + separator.length());
        System.out.println(string + ":" + string.length());
    }

    public static void main(String args[]) {
        SpringApplication.run(Application.class, args);
    }

}

application.properties:

application.separator=\t
application.string=   abc   

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions