diff --git a/test/Grpc.Net.Client.Tests/Balancer/ConnectionManagerTests.cs b/test/Grpc.Net.Client.Tests/Balancer/ConnectionManagerTests.cs index e868c632c..dacecdc5a 100644 --- a/test/Grpc.Net.Client.Tests/Balancer/ConnectionManagerTests.cs +++ b/test/Grpc.Net.Client.Tests/Balancer/ConnectionManagerTests.cs @@ -576,9 +576,10 @@ public async Task PickAsync_UpdateAddressesWhileRequestingConnection_DoesNotDead transportFactory.Transports.ForEach(t => t.Disconnect()); var requestConnectionSyncPoint = new SyncPoint(runContinuationsAsynchronously: true); + var connectionRequestedIntercepted = 0; testSink.MessageLogged += (w) => { - if (w.EventId.Name == "ConnectionRequested") + if (w.EventId.Name == "ConnectionRequested" && Interlocked.CompareExchange(ref connectionRequestedIntercepted, 1, 0) == 0) { logger.LogInformation("Connection has been requested. Waiting for signal to continue..."); requestConnectionSyncPoint.WaitToContinue().Wait();