File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
sdk/core/Azure.Core.TestFramework/src Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 77using System . IO ;
88using System . Reflection ;
99using System . Text . Json ;
10- using System . Threading ;
1110using System . Threading . Tasks ;
1211using Azure . Identity ;
1312using System . ComponentModel ;
1413using System . Linq ;
1514using NUnit . Framework ;
16- using System . Collections . Concurrent ;
1715
1816namespace Azure . Core . TestFramework
1917{
@@ -26,7 +24,7 @@ public abstract class TestEnvironment
2624 [ EditorBrowsableAttribute ( EditorBrowsableState . Never ) ]
2725 public static string RepositoryRoot { get ; }
2826
29- private static readonly ConcurrentDictionary < Type , Task > s_environmentStateCache = new ConcurrentDictionary < Type , Task > ( ) ;
27+ private static readonly Dictionary < Type , Task > s_environmentStateCache = new Dictionary < Type , Task > ( ) ;
3028
3129 private readonly string _prefix ;
3230
@@ -201,7 +199,16 @@ public async ValueTask WaitForEnvironmentAsync()
201199 {
202200 if ( GlobalIsRunningInCI && Mode == RecordedTestMode . Live )
203201 {
204- await s_environmentStateCache . GetOrAdd ( GetType ( ) , t => WaitForEnvironmentInternalAsync ( ) ) ;
202+ Task task ;
203+ lock ( s_environmentStateCache )
204+ {
205+ if ( ! s_environmentStateCache . TryGetValue ( GetType ( ) , out task ) )
206+ {
207+ task = WaitForEnvironmentInternalAsync ( ) ;
208+ s_environmentStateCache [ GetType ( ) ] = task ;
209+ }
210+ }
211+ await task ;
205212 }
206213 }
207214
You can’t perform that action at this time.
0 commit comments