File tree Expand file tree Collapse file tree
src/LaunchDarkly.OpenFeature.ServerProvider Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44using System . Threading . Tasks ;
55using LaunchDarkly . Logging ;
66using LaunchDarkly . Sdk ;
7- using LaunchDarkly . Sdk . Internal . Concurrent ;
87using LaunchDarkly . Sdk . Server ;
98using LaunchDarkly . Sdk . Server . Interfaces ;
109using OpenFeature ;
@@ -32,7 +31,8 @@ public sealed partial class Provider : FeatureProvider
3231 private readonly EvalContextConverter _contextConverter ;
3332 private readonly StatusProvider _statusProvider ;
3433
35- private readonly AtomicBoolean _initializeCalled = new AtomicBoolean ( false ) ;
34+ private readonly object _initLock = new object ( ) ;
35+ private bool _initializeCalled = false ;
3636
3737 // There is no support for void task completion, so we use bool as a dummy result type.
3838 private readonly TaskCompletionSource < bool > _initCompletion = new TaskCompletionSource < bool > ( ) ;
@@ -130,9 +130,13 @@ public override Task<ResolutionDetails<Value>> ResolveStructureValueAsync(string
130130 /// <inheritdoc />
131131 public override Task InitializeAsync ( EvaluationContext context , CancellationToken cancellationToken = default )
132132 {
133- if ( _initializeCalled . GetAndSet ( true ) )
133+ lock ( _initLock )
134134 {
135- return _initCompletion . Task ;
135+ if ( _initializeCalled )
136+ {
137+ return _initCompletion . Task ;
138+ }
139+ _initializeCalled = true ;
136140 }
137141
138142 _client . FlagTracker . FlagChanged += FlagChangeHandler ;
You can’t perform that action at this time.
0 commit comments