diff --git a/projects/RabbitMQ.Client/client/impl/AsyncRpcContinuations.cs b/projects/RabbitMQ.Client/client/impl/AsyncRpcContinuations.cs index bf1bed00a8..4f73677e44 100644 --- a/projects/RabbitMQ.Client/client/impl/AsyncRpcContinuations.cs +++ b/projects/RabbitMQ.Client/client/impl/AsyncRpcContinuations.cs @@ -68,7 +68,8 @@ public AsyncRpcContinuation(TimeSpan continuationTimeout, CancellationToken canc { // Cancellation was successful, does this mean we set a TimeoutException // in the same manner as BlockingCell used to - tcs.SetException(new TimeoutException("TODO LRB rabbitmq/rabbitmq-dotnet-client#1347")); + string msg = $"operation '{GetType().FullName}' timed out after {continuationTimeout}"; + tcs.TrySetException(new TimeoutException(msg)); } }, _tcs); #else @@ -79,7 +80,8 @@ public AsyncRpcContinuation(TimeSpan continuationTimeout, CancellationToken canc { // Cancellation was successful, does this mean we set a TimeoutException // in the same manner as BlockingCell used to - tcs.SetException(new TimeoutException("TODO LRB rabbitmq/rabbitmq-dotnet-client#1347")); + string msg = $"operation '{GetType().FullName}' timed out after {continuationTimeout}"; + tcs.TrySetException(new TimeoutException(msg)); } }, state: _tcs, useSynchronizationContext: false); #endif @@ -109,7 +111,7 @@ public ConfiguredTaskAwaitable.ConfiguredTaskAwaiter GetAwaiter() public virtual void HandleChannelShutdown(ShutdownEventArgs reason) { - _tcs.SetException(new OperationInterruptedException(reason)); + _tcs.TrySetException(new OperationInterruptedException(reason)); } protected virtual void Dispose(bool disposing) diff --git a/projects/Test/Common/IntegrationFixture.cs b/projects/Test/Common/IntegrationFixture.cs index 7be4b371e2..e1a0e5db6e 100644 --- a/projects/Test/Common/IntegrationFixture.cs +++ b/projects/Test/Common/IntegrationFixture.cs @@ -35,6 +35,7 @@ using System.Linq; using System.Net.Sockets; using System.Reflection; +using System.Runtime.CompilerServices; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -619,7 +620,7 @@ protected static string GetUniqueString(ushort length) protected static byte[] GetRandomBody(ushort size = 1024) { - var body = new byte[size]; + byte[] body = new byte[size]; S_Random.NextBytes(body); return body; } @@ -639,5 +640,15 @@ protected static TaskCompletionSource PrepareForRecovery(IConnection conn) return tcs; } + + protected void LogWarning(string text, + [CallerFilePath] string file = "", + [CallerMemberName] string member = "", + [CallerLineNumber] int line = 0) + { + // https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message + _output.WriteLine("::warning file={0},line={1}::{2} {3}", + Path.GetFileName(file), line, member, text); + } } } diff --git a/projects/Test/Integration/ConnectionRecovery/TestRpcAfterRecovery.cs b/projects/Test/Integration/ConnectionRecovery/TestRpcAfterRecovery.cs index 7fbe854e71..92b2d8a22e 100644 --- a/projects/Test/Integration/ConnectionRecovery/TestRpcAfterRecovery.cs +++ b/projects/Test/Integration/ConnectionRecovery/TestRpcAfterRecovery.cs @@ -30,8 +30,6 @@ //--------------------------------------------------------------------------- using System; -using System.IO; -using System.Runtime.CompilerServices; using System.Threading.Tasks; using RabbitMQ.Client; using RabbitMQ.Client.Events; @@ -97,7 +95,7 @@ public async Task TestPublishRpcRightAfterReconnect() */ if (a.ShutdownReason.ReplyCode == 406) { - LogWarning(_output, "FIXME saw code 406"); + LogWarning("FIXME saw code 406"); } } } @@ -106,22 +104,12 @@ public async Task TestPublishRpcRightAfterReconnect() if (now - start > WaitSpan) { - LogWarning(_output, $"FIXME test exceeded wait time of {WaitSpan}"); + LogWarning($"FIXME test exceeded wait time of {WaitSpan}"); } } while (false == doneTcs.Task.IsCompletedSuccessfully()); await closeTask; } - - private static void LogWarning(ITestOutputHelper output, string text, - [CallerFilePath] string file = "", - [CallerMemberName] string member = "", - [CallerLineNumber] int line = 0) - { - // https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message - output.WriteLine($"::warning file={0},line={1}::{2} {3}", - Path.GetFileName(file), line, member, text); - } } }