Skip to content

Commit 4fbcdb6

Browse files
authored
Refactor retry strategies (#4039)
* Refactor the retry strategies This change uses a single class to implement the core logic of all the retries strategies and adds extension points to tailor the behavior when needed. * Rename to BaseRetryStrategy and make it abstract * Remove previous implementations and rename the new ones
1 parent 46e5194 commit 4fbcdb6

File tree

7 files changed

+500
-832
lines changed

7 files changed

+500
-832
lines changed

build-tools/src/main/java/software/amazon/awssdk/buildtools/findbugs/ToBuilderIsCorrect.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,15 @@ public void visit(Method method) {
212212
}
213213
} else if (isBuildable && method.getName().equals("toBuilder") && method.getSignature().startsWith("()")) {
214214
// This is a buildable toBuilder
215-
constructorsInvokedFromToBuilder.computeIfAbsent(getDottedClassName(), n -> new HashMap<>());
216-
toBuilderModifiedFields.computeIfAbsent(getDottedClassName(), n -> new HashMap<>());
215+
String dottedClassName = getDottedClassName();
216+
constructorsInvokedFromToBuilder.computeIfAbsent(dottedClassName, n -> new HashMap<>());
217+
toBuilderModifiedFields.computeIfAbsent(dottedClassName, n -> new HashMap<>());
217218
inBuildableToBuilder = true;
218219
inBuilderConstructor = false;
219-
220+
if (method.isAbstract()) {
221+
// Ignore abstract toBuilder methods, we will still validate the actual implementations.
222+
ignoredBuildables.add(dottedClassName);
223+
}
220224
registerIgnoredFields();
221225
} else {
222226
inBuildableToBuilder = false;

core/retries/src/it/java/software/amazon/awssdk/retries/internal/AdaptiveRetryStrategyResourceConstrainedTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
* perceived availability for the clients to be close to 1.0.
5252
*/
5353
class AdaptiveRetryStrategyResourceConstrainedTest {
54+
static final int DEFAULT_EXCEPTION_TOKEN_COST = 5;
5455

5556
@Test
5657
void seemsToBeCorrectAndThreadSafe() {
@@ -61,12 +62,12 @@ void seemsToBeCorrectAndThreadSafe() {
6162
int parallelism = serverWorkers + clientWorkers;
6263
ExecutorService executor = Executors.newFixedThreadPool(parallelism);
6364
Server server = new Server(serverWorkers, executor);
64-
RateLimiterTokenBucketStore store = RateLimiterTokenBucketStore.builder().build();
6565
AdaptiveRetryStrategy strategy = DefaultAdaptiveRetryStrategy
6666
.builder()
6767
// We don't care about how many attempts we allow to, that logic is tested somewhere else.
6868
// so we give the strategy plenty of room for retries.
6969
.maxAttempts(20)
70+
.tokenBucketExceptionCost(DEFAULT_EXCEPTION_TOKEN_COST)
7071
.tokenBucketStore(TokenBucketStore.builder().tokenBucketMaxCapacity(10_000).build())
7172
// Just wait for the rate limiter delays.
7273
.backoffStrategy(BackoffStrategy.retryImmediately())

0 commit comments

Comments
 (0)