-
Notifications
You must be signed in to change notification settings - Fork 997
Use AWS_NEW_RETRIES_2026 during mode resolution #6872
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
Merged
dagnir
merged 2 commits into
feature/master/2026-new-retries
from
dongie/retry-mode-resolution-v21
Apr 20, 2026
+201
−3
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
core/sdk-core/src/test/java/software/amazon/awssdk/core/SdkSystemSettingNewRetriesTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /* | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://aws.amazon.com/apache2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| package software.amazon.awssdk.core; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.CsvSource; | ||
| import software.amazon.awssdk.testutils.EnvironmentVariableHelper; | ||
|
|
||
| /** | ||
| * Tests for the {@link SdkSystemSetting#AWS_NEW_RETRIES_2026} system setting. | ||
| */ | ||
| class SdkSystemSettingNewRetriesTest { | ||
|
|
||
| @AfterEach | ||
| void cleanup() { | ||
| System.clearProperty(SdkSystemSetting.AWS_NEW_RETRIES_2026.property()); | ||
| } | ||
|
|
||
| @Test | ||
| void defaultsToFalse_whenUnset() { | ||
| assertThat(SdkSystemSetting.AWS_NEW_RETRIES_2026.getBooleanValue()).hasValue(false); | ||
| } | ||
|
|
||
| @ParameterizedTest(name = "systemProperty=\"{0}\" -> {1}") | ||
| @CsvSource({ | ||
| "false, false", | ||
| "true, true" | ||
| }) | ||
| void getBooleanValue_reflectsSystemProperty(String propertyValue, boolean expected) { | ||
| System.setProperty(SdkSystemSetting.AWS_NEW_RETRIES_2026.property(), propertyValue); | ||
| assertThat(SdkSystemSetting.AWS_NEW_RETRIES_2026.getBooleanValue()).hasValue(expected); | ||
| } | ||
|
|
||
| @ParameterizedTest(name = "envVar=\"{0}\" -> {1}") | ||
| @CsvSource({ | ||
| "false, false", | ||
| "true, true" | ||
| }) | ||
| void getBooleanValue_reflectsEnvVar(String envVarValue, boolean expected) { | ||
| EnvironmentVariableHelper.run(helper -> { | ||
| helper.set(SdkSystemSetting.AWS_NEW_RETRIES_2026, envVarValue); | ||
| assertThat(SdkSystemSetting.AWS_NEW_RETRIES_2026.getBooleanValue()).hasValue(expected); | ||
| }); | ||
| } | ||
|
|
||
| @Test | ||
| void systemPropertyTakesPrecedenceOverEnvVar() { | ||
| EnvironmentVariableHelper.run(helper -> { | ||
| System.setProperty(SdkSystemSetting.AWS_NEW_RETRIES_2026.property(), "false"); | ||
| helper.set(SdkSystemSetting.AWS_NEW_RETRIES_2026, "true"); | ||
| assertThat(SdkSystemSetting.AWS_NEW_RETRIES_2026.getBooleanValue()).hasValue(false); | ||
| }); | ||
| } | ||
|
|
||
| @Test | ||
| void environmentVariable_isCorrectName() { | ||
| assertThat(SdkSystemSetting.AWS_NEW_RETRIES_2026.environmentVariable()) | ||
| .isEqualTo("AWS_NEW_RETRIES_2026"); | ||
| } | ||
|
|
||
| @Test | ||
| void systemProperty_isCorrectName() { | ||
| assertThat(SdkSystemSetting.AWS_NEW_RETRIES_2026.property()) | ||
| .isEqualTo("aws.newRetries2026"); | ||
| } | ||
|
|
||
| @Test | ||
| void defaultValue_isFalse() { | ||
| assertThat(SdkSystemSetting.AWS_NEW_RETRIES_2026.defaultValue()) | ||
| .isEqualTo("false"); | ||
| } | ||
| } | ||
104 changes: 104 additions & 0 deletions
104
core/sdk-core/src/test/java/software/amazon/awssdk/core/retry/RetryModeGatedDefaultTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /* | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://aws.amazon.com/apache2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| package software.amazon.awssdk.core.retry; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
|
||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.CsvSource; | ||
| import software.amazon.awssdk.core.SdkSystemSetting; | ||
| import software.amazon.awssdk.testutils.EnvironmentVariableHelper; | ||
|
|
||
| /** | ||
| * Tests for the gated default {@link RetryMode} behavior controlled by | ||
| * {@link SdkSystemSetting#AWS_NEW_RETRIES_2026}. | ||
| */ | ||
| class RetryModeGatedDefaultTest { | ||
|
|
||
| @BeforeEach | ||
| @AfterEach | ||
| void cleanup() { | ||
| System.clearProperty(SdkSystemSetting.AWS_NEW_RETRIES_2026.property()); | ||
| System.clearProperty(SdkSystemSetting.AWS_RETRY_MODE.property()); | ||
| } | ||
|
|
||
| @Test | ||
|
dagnir marked this conversation as resolved.
|
||
| void defaultRetryMode_returnsLegacy_whenGateIsUnset() { | ||
| assertThat(RetryMode.defaultRetryMode()).isEqualTo(RetryMode.LEGACY); | ||
| } | ||
|
|
||
| @ParameterizedTest(name = "gate=\"{0}\" -> {1}") | ||
| @CsvSource({ | ||
| "false, LEGACY", | ||
| "true, STANDARD" | ||
| }) | ||
| void defaultRetryMode_reflectsGate_whenSetViaSystemProperty(String gateValue, RetryMode expected) { | ||
| System.setProperty(SdkSystemSetting.AWS_NEW_RETRIES_2026.property(), gateValue); | ||
| assertThat(RetryMode.defaultRetryMode()).isEqualTo(expected); | ||
| } | ||
|
|
||
| @ParameterizedTest(name = "gate=\"{0}\" -> {1}") | ||
| @CsvSource({ | ||
| "false, LEGACY", | ||
| "true, STANDARD" | ||
| }) | ||
| void defaultRetryMode_reflectsGate_whenSetViaEnvVar(String gateValue, RetryMode expected) { | ||
| EnvironmentVariableHelper.run(helper -> { | ||
| helper.set(SdkSystemSetting.AWS_NEW_RETRIES_2026, gateValue); | ||
| assertThat(RetryMode.defaultRetryMode()).isEqualTo(expected); | ||
| }); | ||
| } | ||
|
|
||
| @Test | ||
| void defaultRetryMode_changesDynamically_whenGateSystemPropertyChangesAtRuntime() { | ||
| // Initially unset — should be LEGACY | ||
| assertThat(RetryMode.defaultRetryMode()).isEqualTo(RetryMode.LEGACY); | ||
|
|
||
| // Enable gate — should switch to STANDARD | ||
| System.setProperty(SdkSystemSetting.AWS_NEW_RETRIES_2026.property(), "true"); | ||
| assertThat(RetryMode.defaultRetryMode()).isEqualTo(RetryMode.STANDARD); | ||
|
|
||
| // Disable gate — should revert to LEGACY | ||
| System.setProperty(SdkSystemSetting.AWS_NEW_RETRIES_2026.property(), "false"); | ||
| assertThat(RetryMode.defaultRetryMode()).isEqualTo(RetryMode.LEGACY); | ||
|
|
||
| // Clear gate — should fall back to default (LEGACY) | ||
| System.clearProperty(SdkSystemSetting.AWS_NEW_RETRIES_2026.property()); | ||
| assertThat(RetryMode.defaultRetryMode()).isEqualTo(RetryMode.LEGACY); | ||
| } | ||
|
|
||
| @ParameterizedTest(name = "gate=\"{0}\" retryMode=\"{1}\" -> {2}") | ||
| @CsvSource({ | ||
| "true, legacy, LEGACY", | ||
| "false, standard, STANDARD", | ||
| "false, adaptive, ADAPTIVE_V2" | ||
| }) | ||
| void resolve_honorsExplicitRetryMode_regardlessOfGate(String gateValue, String retryModeValue, RetryMode expected) { | ||
| System.setProperty(SdkSystemSetting.AWS_NEW_RETRIES_2026.property(), gateValue); | ||
| System.setProperty(SdkSystemSetting.AWS_RETRY_MODE.property(), retryModeValue); | ||
| assertThat(RetryMode.defaultRetryMode()).isEqualTo(expected); | ||
| } | ||
|
|
||
| @Test | ||
| void resolve_throwsIllegalStateException_whenInvalidRetryModeConfigured() { | ||
| System.setProperty(SdkSystemSetting.AWS_RETRY_MODE.property(), "invalid_mode"); | ||
| assertThatThrownBy(RetryMode::defaultRetryMode).isInstanceOf(IllegalStateException.class); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.