Commit 0e32c0a7 authored by Phillip Webb's avatar Phillip Webb

Fix speed regression in property binding

Update `MapBinder` to only compute values if an entry does not already
exist. Prior to this commit, a binding to `Map<String,List<String>>`
would be expensive since the same entries would be bound many times.

For example, given:

	foo.bar[0]=baz1
	foo.bar[1]=baz1
	foo.bar[2]=baz1

The Map binder would iterate over the properties `bar[0]`, `bar[1]` and
`bar[2]`. Each of these properties resulted in the same actual key of
`bar` which would then be bound to list multiple times.

Fixes gh-10093
parent 402dcb7e
...@@ -103,8 +103,8 @@ class MapBinder extends AggregateBinder<Map<Object, Object>> { ...@@ -103,8 +103,8 @@ class MapBinder extends AggregateBinder<Map<Object, Object>> {
ConfigurationPropertyName entryName = getEntryName(source, name); ConfigurationPropertyName entryName = getEntryName(source, name);
Object key = getContext().getConversionService() Object key = getContext().getConversionService()
.convert(getKeyName(entryName), this.keyType); .convert(getKeyName(entryName), this.keyType);
Object value = this.elementBinder.bind(entryName, valueBindable); map.computeIfAbsent(key,
map.putIfAbsent(key, value); (k) -> this.elementBinder.bind(entryName, valueBindable));
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment