Commit 99dc7914 authored by Phillip Webb's avatar Phillip Webb

Attempt to fix ConcurrentModificationException

Attempt to fix `ConcurrentModificationException` which occurs on
Java 11+.

See gh-23326
parent cad079ce
...@@ -88,7 +88,12 @@ public class DefaultBootstrapContext implements ConfigurableBootstrapContext { ...@@ -88,7 +88,12 @@ public class DefaultBootstrapContext implements ConfigurableBootstrapContext {
synchronized (this.instanceSuppliers) { synchronized (this.instanceSuppliers) {
InstanceSupplier<?> instanceSupplier = this.instanceSuppliers.get(type); InstanceSupplier<?> instanceSupplier = this.instanceSuppliers.get(type);
Assert.state(instanceSupplier != null, () -> type.getName() + " has not been registered"); Assert.state(instanceSupplier != null, () -> type.getName() + " has not been registered");
return (T) this.instances.computeIfAbsent(type, (key) -> instanceSupplier.get(this)); T instance = (T) this.instances.get(type);
if (instance == null) {
instance = (T) instanceSupplier.get(this);
this.instances.put(type, instance);
}
return instance;
} }
} }
......
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