Repository: dotnet/runtime
File: src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestBase.cs (C#)

Code before:
                disposeListener = true;
            }

            clientOptions ??= CreateQuicClientOptions();
            if (clientOptions.RemoteEndPoint == null)
            {
                clientOptions.RemoteEndPoint = listener.ListenEndPoint;
            }

            QuicConnection clientConnection = null;
            ValueTask<QuicConnection> serverTask = listener.AcceptConnectionAsync();
            while (retry > 0)
            {
                clientConnection = CreateQuicConnection(clientOptions);
                retry--;
                try
                {
                    await clientConnection.ConnectAsync().ConfigureAwait(false);
                    break;
                } catch (QuicException ex) when (ex.HResult == (int)SocketError.ConnectionRefused)
                {
                    _output.WriteLine($"ConnectAsync to {clientConnection.RemoteEndPoint} failed with {ex.Message}");
                    await Task.Delay(delay);
                    delay *= 2;

                    if (retry ==0)
                    {
                        Debug.Fail($"ConnectAsync to {clientConnection.RemoteEndPoint} failed with {ex.Message}");
                    }
                }
            }

            QuicConnection serverConnection = await serverTask.ConfigureAwait(false);
            if (disposeListener)
            {
                listener.Dispose();
            }

            Assert.True(serverConnection.Connected);
            Assert.True(clientConnection.Connected);

            return (clientConnection, serverTask.Result);
        }

        internal async Task PingPong(QuicConnection client, QuicConnection server)
        {
            using QuicStream clientStream = client.OpenBidirectionalStream();
            ValueTask t = clientStream.WriteAsync(s_ping);
            using QuicStream serverStream = await server.AcceptStreamAsync();

            byte[] buffer = new byte[s_ping.Length];

Review comment (suggestion):
```suggestion
                    if (retry == 0)
```

Code after:
                disposeListener = true;
            }

            clientOptions ??= CreateQuicClientOptions();
            if (clientOptions.RemoteEndPoint == null)
            {
                clientOptions.RemoteEndPoint = listener.ListenEndPoint;
            }

            QuicConnection clientConnection = null;
            ValueTask<QuicConnection> serverTask = listener.AcceptConnectionAsync();
            while (retry > 0)
            {
                clientConnection = CreateQuicConnection(clientOptions);
                retry--;
                try
                {
                    await clientConnection.ConnectAsync().ConfigureAwait(false);
                    break;
                }
                catch (QuicException ex) when (ex.HResult == (int)SocketError.ConnectionRefused)
                {
                    _output.WriteLine($"ConnectAsync to {clientConnection.RemoteEndPoint} failed with {ex.Message}");
                    await Task.Delay(delay);
                    delay *= 2;

                    if (retry == 0)
                    {
                        Debug.Fail($"ConnectAsync to {clientConnection.RemoteEndPoint} failed with {ex.Message}");
                    }
                }
            }

            QuicConnection serverConnection = await serverTask.ConfigureAwait(false);
            if (disposeListener)
            {
                listener.Dispose();
            }

            Assert.True(serverConnection.Connected);
            Assert.True(clientConnection.Connected);

            return (clientConnection, serverTask.Result);
        }

        internal async Task PingPong(QuicConnection client, QuicConnection server)
        {
            using QuicStream clientStream = client.OpenBidirectionalStream();
            ValueTask t = clientStream.WriteAsync(s_ping);
            using QuicStream serverStream = await server.AcceptStreamAsync();