AutoGrow not applied for nested map values #32154
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Uh oh!
There was an error while loading. Please reload this page.
Affects: 6.0.8
Language: Kotlin
Spring Version: 6.0.8
I am using data binding for parsing form data into a form object. When using a singly nested map (
Map<String, Map<String, String>
), I find that using the keyproperty[map1key][map2key]
works as expected to set the nested value, but when adding another layer, e.g.Map<String, Map<String, Map<String, String>>>
with keyproperty[map1key][map2key][map3key]
this fails with an exceptioncannot access indexed value of property referenced in indexed property path nested map
.Looking into the source code, I believe I tracked it down to the
AbstractNestablePropertyAccessor.getPropertyValue(PropertyTokenHolder tokens)
method which seems to only set the default value on the first token which explains why this works for a singly nested map but not a double or greater one. I suspect this affects any type of auto growing collection as well.relevant snippet:
As a workaround, I'm using a single map with a custom key that I deserialize manually and then convert to a nested map in application code, but it would be nice if this was supported as part of the data binding.
The text was updated successfully, but these errors were encountered: