Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better exception message when a continuation times out #1552

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions projects/RabbitMQ.Client/client/impl/AsyncRpcContinuations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -109,7 +111,7 @@ public ConfiguredTaskAwaitable<T>.ConfiguredTaskAwaiter GetAwaiter()

public virtual void HandleChannelShutdown(ShutdownEventArgs reason)
{
_tcs.SetException(new OperationInterruptedException(reason));
_tcs.TrySetException(new OperationInterruptedException(reason));
}

protected virtual void Dispose(bool disposing)
Expand Down
13 changes: 12 additions & 1 deletion projects/Test/Common/IntegrationFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -639,5 +640,15 @@ protected static TaskCompletionSource<bool> 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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
//---------------------------------------------------------------------------

using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
Expand Down Expand Up @@ -97,7 +95,7 @@ public async Task TestPublishRpcRightAfterReconnect()
*/
if (a.ShutdownReason.ReplyCode == 406)
{
LogWarning(_output, "FIXME saw code 406");
LogWarning("FIXME saw code 406");
}
}
}
Expand All @@ -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);
}
}
}
Loading