Skip to content

Commit 6b9e1cc

Browse files
authored
Revert commits related to the new RetryPolicy method (#5793)
* Revert "Update the RetryPolicy for the GA release, keeping ShouldRetry extension point hidden. (#5771)" This reverts commit 9ccd206. * Revert "Update the RetryPolicy and ShouldRetry customization logic to allow loosening the retry condition. (#5656)" This reverts commit f1d9552. * Do not remove changelog entry from a previous beta release * Revert "Add a virtual ShouldRetry method to the RetryPolicy for customization. (#5584)" This reverts commit ab90ef6. --------- Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
1 parent e8c7c55 commit 6b9e1cc

4 files changed

Lines changed: 131 additions & 417 deletions

File tree

sdk/core/azure-core/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
### Other Changes
1010

1111
- Updated JSON library to 3.11.3.
12-
- Hide methods on the `RetryPolicy` that are not intended for public use.
1312
- [[#5622]](https://github.com/Azure/azure-sdk-for-cpp/pull/5622) Documentation fix for building the SDK with specific OpenSSL version. (A community contribution, courtesy of _[ByteYue](https://github.com/ByteYue)_)
1413

1514
### Acknowledgments

sdk/core/azure-core/inc/azure/core/http/policies/policy.hpp

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@
3030
#include <utility>
3131
#include <vector>
3232

33-
#if defined(_azure_TESTING_BUILD)
34-
// Define the classes used from tests
35-
namespace Azure { namespace Core { namespace Test {
36-
class RetryPolicyTest;
37-
class RetryLogic;
38-
}}} // namespace Azure::Core::Test
39-
#endif
40-
4133
/**
4234
* A function that should be implemented and linked to the end-user application in order to override
4335
* an HTTP transport implementation provided by Azure SDK with custom implementation.
@@ -376,11 +368,6 @@ namespace Azure { namespace Core { namespace Http { namespace Policies {
376368
final
377369
#endif
378370
: public HttpPolicy {
379-
#if defined(_azure_TESTING_BUILD)
380-
// make tests classes friends
381-
friend class Azure::Core::Test::RetryPolicyTest;
382-
friend class Azure::Core::Test::RetryLogic;
383-
#endif
384371
private:
385372
RetryOptions m_retryOptions;
386373

@@ -415,7 +402,7 @@ namespace Azure { namespace Core { namespace Http { namespace Policies {
415402
*/
416403
static int32_t GetRetryCount(Context const& context);
417404

418-
private:
405+
protected:
419406
virtual bool ShouldRetryOnTransportFailure(
420407
RetryOptions const& retryOptions,
421408
int32_t attempt,
@@ -428,26 +415,6 @@ namespace Azure { namespace Core { namespace Http { namespace Policies {
428415
int32_t attempt,
429416
std::chrono::milliseconds& retryAfter,
430417
double jitterFactor = -1) const;
431-
432-
/**
433-
* @brief Overriding this method customizes the logic of when the RetryPolicy will re-attempt
434-
* a request, based on the returned HTTP response.
435-
*
436-
* @remark A null response pointer means there was no response received from the corresponding
437-
* request. Custom implementations of this method that override the retry behavior, should
438-
* handle that error case, if that needs to be customized.
439-
*
440-
* @remark Unless overriden, the default implementation is to always return `false`. The
441-
* non-retriable errors, including those specified in the RetryOptions, remain evaluated
442-
* before calling ShouldRetry.
443-
*
444-
* @param response An HTTP response returned corresponding to the request sent by the policy.
445-
* @param retryOptions The set of options provided to the RetryPolicy.
446-
* @return Whether or not the HTTP request should be sent again through the pipeline.
447-
*/
448-
virtual bool ShouldRetry(
449-
std::unique_ptr<RawResponse> const& response,
450-
RetryOptions const& retryOptions) const;
451418
};
452419

453420
/**

sdk/core/azure-core/src/http/retry_policy.cpp

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ int32_t RetryPolicy::GetRetryCount(Context const& context)
118118
return *ptr;
119119
}
120120

121-
bool RetryPolicy::ShouldRetry(std::unique_ptr<RawResponse> const&, RetryOptions const&) const
122-
{
123-
return false;
124-
}
125-
126121
std::unique_ptr<RawResponse> RetryPolicy::Send(
127122
Request& request,
128123
NextHttpPolicy nextPolicy,
@@ -145,24 +140,9 @@ std::unique_ptr<RawResponse> RetryPolicy::Send(
145140
{
146141
auto response = nextPolicy.Send(request, retryContext);
147142

148-
// Are we out of retry attempts?
149-
// Checking this first, before checking the response so that the extension point of
150-
// ShouldRetry doesn't have the responsibility of checking the number of retries (again).
151-
if (WasLastAttempt(m_retryOptions, attempt))
152-
{
153-
return response;
154-
}
155-
156-
// If a response is non-retriable (or simply 200 OK, i.e doesn't need to be retried), then
157-
// ShouldRetryOnResponse returns false. Service SDKs can inject custom logic to define whether
158-
// the request should be retried, based on the response. The default of `ShouldRetry` is
159-
// false.
160-
// Because of boolean short-circuit evaluation, if ShouldRetryOnResponse returns true, the
161-
// overriden ShouldRetry is not called. This is expected, since overriding ShouldRetry enables
162-
// loosening the retry conditions (retrying where otherwise the request wouldn't be), but not
163-
// strengthening it.
164-
if (!ShouldRetryOnResponse(*response.get(), m_retryOptions, attempt, retryAfter)
165-
&& !ShouldRetry(response, m_retryOptions))
143+
// If we are out of retry attempts, if a response is non-retriable (or simply 200 OK, i.e
144+
// doesn't need to be retried), then ShouldRetry returns false.
145+
if (!ShouldRetryOnResponse(*response.get(), m_retryOptions, attempt, retryAfter))
166146
{
167147
// If this is the second attempt and StartTry was called, we need to stop it. Otherwise
168148
// trying to perform same request would use last retry query/headers
@@ -235,6 +215,12 @@ bool RetryPolicy::ShouldRetryOnResponse(
235215
using Azure::Core::Diagnostics::Logger;
236216
using Azure::Core::Diagnostics::_internal::Log;
237217

218+
// Are we out of retry attempts?
219+
if (WasLastAttempt(retryOptions, attempt))
220+
{
221+
return false;
222+
}
223+
238224
// Should we retry on the given response retry code?
239225
{
240226
auto const& statusCodes = retryOptions.StatusCodes;

0 commit comments

Comments
 (0)