Skip to content

Clarify when retaining . characters in property keys requires bracket notation to be used #23390

Closed
@wilkinsona

Description

@wilkinsona

The documentation currently states the following:

When binding to Map properties, if the key contains anything other than lowercase alpha-numeric characters or -, you need to use the bracket notation so that the original value is preserved. If the key is not surrounded by [], any characters that are not alpha-numeric or - are removed.

This isn't entirely accurate as . characters do not always require the use of bracket notation to be retained. Consider the following application.properties:

example.properties.alpha.bravo=one
example.properties.[charlie.delta]=two

And the following @ConfigurationProperties

@ConfigurationProperties("example")
class ExampleProperties {
	
	private final Properties properties = new Properties();

	public Properties getProperties() {
		return properties;
	}

}

Binding results in properties having the following content:

{charlie.delta=two, alpha.bravo=one}

Note that the . in the property key has been retained in both cases.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions