diff --git a/src/Elastic.Transport/DistributedTransport.cs b/src/Elastic.Transport/DistributedTransport.cs index 018ca33..99373b4 100644 --- a/src/Elastic.Transport/DistributedTransport.cs +++ b/src/Elastic.Transport/DistributedTransport.cs @@ -305,13 +305,20 @@ BoundConfiguration GetOrCreateBoundConfiguration(RequestConfiguration rc) return boundConfiguration; } +#if NET8_0_OR_GREATER boundConfiguration = new BoundConfiguration(Configuration, rc); -#if NET8_0_OR_GREATER cache.TryAdd(rc, boundConfiguration); #else lock (cache) { + if (cache.TryGetValue(rc, out boundConfiguration)) + { + return boundConfiguration; + } + + boundConfiguration = new BoundConfiguration(Configuration, rc); + cache.Add(rc, boundConfiguration); } #endif