Skip to content

Allow YAML processors to create a flattened map with nulls included#36197

Merged
jhoeller merged 1 commit intospring-projects:mainfrom
philwebb:yaml-nulls
Jan 23, 2026
Merged

Allow YAML processors to create a flattened map with nulls included#36197
jhoeller merged 1 commit intospring-projects:mainfrom
philwebb:yaml-nulls

Conversation

@philwebb
Copy link
Member

Whilst looking into spring-projects/spring-boot#48920 I realized we don't currently have a good way to flatten a YAML map and retain null values. Whilst we could do this in Spring Boot, it would mean duplicating code so I wonder if we can add a new method here instead.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 23, 2026
Add an additional `getFlattenedMap` method to `YamlProcessor` to allow
the resulting flattened map to include nulls.

This update will allow processor subclasses to tell the difference
between YAML that is defined with an empty object vs missing the key
entirely:

e.g.:

  application:
    name: test
    optional: {}

vs

  application:
    name: test
    optional: {}

Closes spring-projectsgh-36197

Signed-off-by: Phillip Webb <phil.webb@broadcom.com>
@jhoeller jhoeller self-assigned this Jan 23, 2026
@jhoeller jhoeller added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 23, 2026
@jhoeller jhoeller added this to the 7.0.4 milestone Jan 23, 2026
@jhoeller jhoeller merged commit 0c9f40b into spring-projects:main Jan 23, 2026
4 checks passed
philwebb added a commit to philwebb/spring-framework that referenced this pull request Jan 24, 2026
Update `YamlProcessor` to allow any value to be inserted for
empty entries. This update will allow blank strings to be used
instead of `null` which better aligns with the way that
`.properties` files are loaded.

This update also allows allows the specified `emptyValue` to be
inserted instead of a blank String when the YAML contains `null`
or `~` values.

See spring-projectsgh-36197
See spring-projectsgh-19986

Signed-off-by: Phillip Webb <phil.webb@broadcom.com>
philwebb added a commit to philwebb/spring-framework that referenced this pull request Jan 24, 2026
Update `YamlProcessor` to allow any value to be inserted for
empty entries. This update will allow blank strings to be used
instead of `null` which better aligns with the way that
`.properties` files are loaded.

This update also allows allows the specified `emptyValue` to be
inserted instead of a blank String when the YAML contains `null`
or `~` values.

See spring-projectsgh-36197
See spring-projectsgh-19986

Signed-off-by: Phillip Webb <phil.webb@broadcom.com>
jhoeller pushed a commit that referenced this pull request Jan 24, 2026
Update `YamlProcessor` to allow any value to be inserted for
empty entries. This update will allow blank strings to be used
instead of `null` which better aligns with the way that
`.properties` files are loaded.

This update also allows allows the specified `emptyValue` to be
inserted instead of a blank String when the YAML contains `null`
or `~` values.

See gh-36197
See gh-19986

Signed-off-by: Phillip Webb <phil.webb@broadcom.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants