From 7ee548f94e6c0f52c5d2aec08e8e2eed59d37d40 Mon Sep 17 00:00:00 2001 From: Kendall Bennett Date: Tue, 8 Nov 2022 12:20:22 -0500 Subject: [PATCH] Throw exception on disposed. We should always throw this one as it is pretty fatal so you would not want this to silently show up in the Exception response value. --- src/RestSharp/RestClient.Async.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/RestSharp/RestClient.Async.cs b/src/RestSharp/RestClient.Async.cs index 0a57d189f..24682b1ee 100644 --- a/src/RestSharp/RestClient.Async.cs +++ b/src/RestSharp/RestClient.Async.cs @@ -48,6 +48,11 @@ public async Task ExecuteAsync(RestRequest request, CancellationTo async Task ExecuteInternal(RestRequest request, CancellationToken cancellationToken) { Ensure.NotNull(request, nameof(request)); + // Make sure we are not disposed of when someone tries to call us! + if (_disposed) { + throw new ObjectDisposedException(nameof(RestClient)); + } + using var requestContent = new RequestContent(this, request); if (Authenticator != null) await Authenticator.Authenticate(this, request).ConfigureAwait(false);