Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@ConfigurationProperties map parser ignores line after empty comment line #24333

Closed
lukasherman opened this issue Dec 4, 2020 · 1 comment
Closed
Labels
status: duplicate A duplicate of another issue

Comments

@lukasherman
Copy link

Found in Spring Boot v2.4.0 (works in v2.3.x)
application.properties to Map parser behavior has changed significantly, now a line following empty comment is ignored.

Example (failing)

#
property.map.key1=value1
property.map.key2=value2

Example (working):

# non-empty comment
property.map.key1=value1
property.map.key2=value2

Reproducer

ConfigTest.java

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;

@SpringBootTest(classes = ConfigTest.Property.class)
@ActiveProfiles("propertytest")
@EnableConfigurationProperties
public class ConfigTest {
    @Autowired
    private Property property;

    @Test
    public void testProperty() {
        assertEquals(2, property.getMap().size());
    }

    @ConfigurationProperties("property")
    public static class Property {
        private Map<String, String> map;

        public Map<String, String> getMap() {
            return map;
        }

        public void setMap(Map<String, String> map) {
            this.map = map;
        }
    }
}

application-propertytest.properties

#
property.map.key1=value1
property.map.key2=value2
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 4, 2020
@bclozel
Copy link
Member

bclozel commented Dec 4, 2020

This is a duplicate of #24158, which is already fixed in 2.4.1-SNAPSHOT.
Thanks for the report!

@bclozel bclozel closed this as completed Dec 4, 2020
@bclozel bclozel added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants