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
@ConstructorBinding
@ConfigurationProperties("prefix")
data classObjProperties(valobj:Map<String, FooBarProperties>)
@ConstructorBinding
data classFooBarProperties(valfirstName:String? = "", vallastName:String? = "")
I was expecting that injecting ObjProperties bean will result in having both foo property and bar property in obj map. Unfortunately, bar property is missing from the objmap.
The text was updated successfully, but these errors were encountered:
Thanks for the issue report, @jntakpe. We spent some time discussing this today and concluded that this it isn't something that we want to try and support. Configuration property binding is backed by Spring Framework's Environment and PropertySource abstractions. The later is a "source of name/value property pairs". As such, there's no way to represent the YAML-specific concept of an empty object that could then be used by the property binding to know that an empty instance of FooBarProperties should be created.
Adding origin support caused an unexpected and unwanted change
in behavior where configuration property binding would fail. The
failure would occur because there was no way to convert from the
entry in the environment that represents the empty map to the
target type.
The commit changes the YAML loader to drop empty maps,
effectively reverting the map portion of
3bcbb0e and gh-21704. This aligns
the behavior with the decision we made in gh-19095.
Origin support for an empty list has been retained as it does not
have a negative effect on configuration property binding. Prior to
these changes, an empty YAML list was mapped to an origin tracked
value that contains an empty list. Fully reverting
3bcbb0e would have resulted in an
empty YAML list being mapped to an empty string. To avoid adding a
collection type to the environment, we now map an empty YAML list
to an origin tracked value that contains an empty string.
Closesgh-35403
Spring Boot version: 2.2.1.RELEASE
Having the following properties
And given the following properties class
I was expecting that injecting ObjProperties bean will result in having both
foo
property andbar
property inobj
map. Unfortunately,bar
property is missing from theobj
map.The text was updated successfully, but these errors were encountered: