Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public class CustomizationConfig {
/**
* Whether the client will apply a default read/write timeout by default.
*/
private Boolean defaultEnableReadTimeout2026;
private Boolean defaultEnableSocketTimeout2026;

/**
* Whether to generate an abstract decorator class that delegates to the async service client
Expand Down Expand Up @@ -742,12 +742,12 @@ public void setDefaultNewRetries2026(Boolean defaultNewRetries2026) {
this.defaultNewRetries2026 = defaultNewRetries2026;
}

public Boolean getDefaultEnableReadTimeout2026() {
return defaultEnableReadTimeout2026;
public Boolean getDefaultEnableSocketTimeout2026() {
return defaultEnableSocketTimeout2026;
}

public void setDefaultEnableReadTimeout2026(Boolean defaultEnableReadTimeout2026) {
this.defaultEnableReadTimeout2026 = defaultEnableReadTimeout2026;
public void setDefaultEnableSocketTimeout2026(Boolean defaultEnableSocketTimeout2026) {
this.defaultEnableSocketTimeout2026 = defaultEnableSocketTimeout2026;
}

public ServiceConfig getServiceConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ private Optional<MethodSpec> mergeInternalDefaultsMethod() {
String userAgent = model.getCustomizationConfig().getUserAgent();
RetryMode defaultRetryMode = model.getCustomizationConfig().getDefaultRetryMode();
Boolean defaultNewRetries2026 = model.getCustomizationConfig().getDefaultNewRetries2026();
Boolean defaultEnableReadTimeout2026 = model.getCustomizationConfig().getDefaultEnableReadTimeout2026();
Boolean defaultEnableSocketTimeout2026 = model.getCustomizationConfig().getDefaultEnableSocketTimeout2026();

// If none of the options are customized, then we do not need to bother overriding the method
if (!hasInternalDefaults()) {
Expand All @@ -357,9 +357,9 @@ private Optional<MethodSpec> mergeInternalDefaultsMethod() {
builder.addCode("c.option($T.DEFAULT_NEW_RETRIES_2026, $L);\n",
SdkClientOption.class, defaultNewRetries2026);
}
if (defaultEnableReadTimeout2026 != null) {
builder.addCode("c.option($T.DEFAULT_ENABLE_READ_TIMEOUT_2026, $L);\n",
SdkClientOption.class, defaultEnableReadTimeout2026);
if (defaultEnableSocketTimeout2026 != null) {
builder.addCode("c.option($T.DEFAULT_ENABLE_SOCKET_TIMEOUT_2026, $L);\n",
SdkClientOption.class, defaultEnableSocketTimeout2026);
}
builder.addCode("});\n");
return Optional.of(builder.build());
Expand All @@ -370,7 +370,7 @@ private boolean hasInternalDefaults() {
return customizationConfig.getUserAgent() != null
|| customizationConfig.getDefaultRetryMode() != null
|| customizationConfig.getDefaultNewRetries2026() != null
|| customizationConfig.getDefaultEnableReadTimeout2026() != null;
|| customizationConfig.getDefaultEnableSocketTimeout2026() != null;
}

private MethodSpec finalizeServiceConfigurationMethod() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected final SdkClientConfiguration mergeInternalDefaults(SdkClientConfigurat
c.option(SdkClientOption.INTERNAL_USER_AGENT, "md/foobar");
c.option(SdkClientOption.DEFAULT_RETRY_MODE, RetryMode.STANDARD);
c.option(SdkClientOption.DEFAULT_NEW_RETRIES_2026, true);
c.option(SdkClientOption.DEFAULT_ENABLE_READ_TIMEOUT_2026, true);
c.option(SdkClientOption.DEFAULT_ENABLE_SOCKET_TIMEOUT_2026, true);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"userAgent": "md/foobar",
"defaultRetryMode": "STANDARD",
"defaultNewRetries2026": "true",
"defaultEnableReadTimeout2026": "true"
"defaultEnableSocketTimeout2026": "true"
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption;
import software.amazon.awssdk.core.client.config.SdkClientConfiguration;
import software.amazon.awssdk.core.client.config.SdkClientOption;
import software.amazon.awssdk.core.http.EnableDefaultReadTimeout2026Resolver;
import software.amazon.awssdk.core.http.EnableDefaultSocketTimeout2026Resolver;
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
import software.amazon.awssdk.core.internal.SdkInternalTestAdvancedClientOption;
import software.amazon.awssdk.core.internal.retry.SdkDefaultRetryStrategy;
Expand Down Expand Up @@ -263,10 +263,10 @@ private AttributeMap resolveHttpClientConfig(LazyValueSource config) {
}

/**
* Applies the {@code AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026} rollout gate to the codegen-baked
* Applies the {@code AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026} rollout gate to the codegen-baked
* {@link SdkHttpConfigurationOption#SDK_INTERNAL_FALLBACK_READ_WRITE_TIMEOUT} contributed by {@link #serviceHttpConfig()}.
* The gate resolves from the {@code AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026} environment variable/system property, else the
* codegen-baked {@link SdkClientOption#DEFAULT_ENABLE_READ_TIMEOUT_2026} default, else off.
* The gate resolves from the {@code AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026} environment variable/system property, else the
* codegen-baked {@link SdkClientOption#DEFAULT_ENABLE_SOCKET_TIMEOUT_2026} default, else off.
*
* <p>When the gate is on, an unlisted service (nothing baked) gets the flat 5-minute default and a baked tier is kept as-is
* ({@link Duration#ZERO} for fully-exempt, 15 minutes for partial). When the gate is off, a baked positive tier (partial)
Expand All @@ -275,8 +275,8 @@ private AttributeMap resolveHttpClientConfig(LazyValueSource config) {
* not truthy, so the HTTP client's option-absent path applies nothing either way.
*/
private AttributeMap applyDefaultReadWriteTimeout(LazyValueSource config, AttributeMap serviceHttpConfig) {
boolean gateEnabled = new EnableDefaultReadTimeout2026Resolver()
.defaultEnableReadTimeout2026(config.get(SdkClientOption.DEFAULT_ENABLE_READ_TIMEOUT_2026))
boolean gateEnabled = new EnableDefaultSocketTimeout2026Resolver()
.defaultEnableSocketTimeout2026(config.get(SdkClientOption.DEFAULT_ENABLE_SOCKET_TIMEOUT_2026))
.resolve();

Duration bakedTier = serviceHttpConfig.get(SdkHttpConfigurationOption.SDK_INTERNAL_FALLBACK_READ_WRITE_TIMEOUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@
import software.amazon.awssdk.utils.AttributeMap;

/**
* Verifies the {@code AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026} rollout gate applied in
* Verifies the {@code AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026} rollout gate applied in
* {@link AwsDefaultClientBuilder#resolveHttpClientConfig} to the codegen-baked
* {@link SdkHttpConfigurationOption#SDK_INTERNAL_FALLBACK_READ_WRITE_TIMEOUT}.
*/
@ExtendWith(MockitoExtension.class)
class AwsDefaultClientBuilderReadWriteTimeoutTest {

private static final String GATE_PROPERTY = SdkSystemSetting.AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026.property();
private static final String GATE_PROPERTY = SdkSystemSetting.AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026.property();
private static final Duration PARTIAL_TIER = Duration.ofMinutes(15);
private static final Duration FLAT_DEFAULT = Duration.ofMinutes(5);

Expand Down Expand Up @@ -168,7 +168,7 @@ protected SdkClientConfiguration mergeInternalDefaults(SdkClientConfiguration co
if (!codegenGateDefault) {
return config;
}
return config.merge(c -> c.option(SdkClientOption.DEFAULT_ENABLE_READ_TIMEOUT_2026, true));
return config.merge(c -> c.option(SdkClientOption.DEFAULT_ENABLE_SOCKET_TIMEOUT_2026, true));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public enum SdkSystemSetting implements SystemSetting {
* <p>This setting is not intended to be used by end users. It gates an interim rollout and is subject to removal in a
* future release.
*/
AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026("aws.enableDefaultReadTimeout2026", null);
AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026("aws.enableDefaultSocketTimeout2026", null);

private final String systemProperty;
private final String defaultValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,11 @@ public final class SdkClientOption<T> extends ClientOption<T> {
public static final SdkClientOption<Boolean> DEFAULT_NEW_RETRIES_2026 = new SdkClientOption<>(Boolean.class);

/**
* Option to specify the default for the {@code AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026} feature gate for the SDK client.
* Option to specify the default for the {@code AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026} feature gate for the SDK client.
* This option is not intended to be set by end users. It gates an interim rollout and is subject to removal in a future
* release.
*/
public static final SdkClientOption<Boolean> DEFAULT_ENABLE_READ_TIMEOUT_2026 = new SdkClientOption<>(Boolean.class);
public static final SdkClientOption<Boolean> DEFAULT_ENABLE_SOCKET_TIMEOUT_2026 = new SdkClientOption<>(Boolean.class);

/**
* Whether retries 2.1 behavior is enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,36 @@
import software.amazon.awssdk.core.SdkSystemSetting;

/**
* Resolver for the {@link SdkSystemSetting#AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026} that supports setting a fallback value if not
* Resolver for the {@link SdkSystemSetting#AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026} that supports setting a fallback value if not
* defined in the environment or system properties.
*/
@SdkProtectedApi
public final class EnableDefaultReadTimeout2026Resolver {
private Boolean defaultEnableReadTimeout2026;
public final class EnableDefaultSocketTimeout2026Resolver {
private Boolean defaultEnableSocketTimeout2026;

/**
* The default value for {@code AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026} if not configured via
* {@link SdkSystemSetting#AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026}.
* The default value for {@code AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026} if not configured via
* {@link SdkSystemSetting#AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026}.
*
* @return This resolver for method chaining.
*/
public EnableDefaultReadTimeout2026Resolver defaultEnableReadTimeout2026(Boolean defaultEnableReadTimeout2026) {
this.defaultEnableReadTimeout2026 = defaultEnableReadTimeout2026;
public EnableDefaultSocketTimeout2026Resolver defaultEnableSocketTimeout2026(Boolean defaultEnableSocketTimeout2026) {
this.defaultEnableSocketTimeout2026 = defaultEnableSocketTimeout2026;
return this;
}

/**
* Resolve whether a default read/write timeout is applied.
*/
public boolean resolve() {
Optional<Boolean> envConfig = SdkSystemSetting.AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026.getBooleanValue();
Optional<Boolean> envConfig = SdkSystemSetting.AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026.getBooleanValue();

if (envConfig.isPresent()) {
return envConfig.get();
}

if (defaultEnableReadTimeout2026 != null) {
return defaultEnableReadTimeout2026;
if (defaultEnableSocketTimeout2026 != null) {
return defaultEnableSocketTimeout2026;
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,51 +27,51 @@
import software.amazon.awssdk.core.SdkSystemSetting;
import software.amazon.awssdk.testutils.EnvironmentVariableHelper;

public class EnableDefaultReadTimeout2026ResolverTest {
private static String enableDefaultReadTimeout2026Save;
public class EnableDefaultSocketTimeout2026ResolverTest {
private static String enableDefaultSocketTimeout2026Save;

@BeforeAll
static void setup() {
enableDefaultReadTimeout2026Save = System.getProperty(SdkSystemSetting.AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026.property());
enableDefaultSocketTimeout2026Save = System.getProperty(SdkSystemSetting.AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026.property());
}

@AfterAll
static void teardown() {
if (enableDefaultReadTimeout2026Save != null) {
System.setProperty(SdkSystemSetting.AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026.property(),
enableDefaultReadTimeout2026Save);
if (enableDefaultSocketTimeout2026Save != null) {
System.setProperty(SdkSystemSetting.AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026.property(),
enableDefaultSocketTimeout2026Save);
} else {
System.clearProperty(SdkSystemSetting.AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026.property());
System.clearProperty(SdkSystemSetting.AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026.property());
}
}

@BeforeEach
void methodSetup() {
System.clearProperty(SdkSystemSetting.AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026.property());
System.clearProperty(SdkSystemSetting.AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026.property());
}

@Test
void systemSetting_usesExpectedEnvironmentVariableAndSystemPropertyNames() {
assertThat(SdkSystemSetting.AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026.environmentVariable())
.isEqualTo("AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026");
assertThat(SdkSystemSetting.AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026.property())
.isEqualTo("aws.enableDefaultReadTimeout2026");
assertThat(SdkSystemSetting.AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026.environmentVariable())
.isEqualTo("AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026");
assertThat(SdkSystemSetting.AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026.property())
.isEqualTo("aws.enableDefaultSocketTimeout2026");
}

@ParameterizedTest
@MethodSource("params")
void resolve_behavesCorrectly(TestParams params) {
EnvironmentVariableHelper.run((env) -> {
if (params.systemProperty != null) {
System.setProperty(SdkSystemSetting.AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026.property(), params.systemProperty);
System.setProperty(SdkSystemSetting.AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026.property(), params.systemProperty);
}

if (params.envVar != null) {
env.set(SdkSystemSetting.AWS_ENABLE_DEFAULT_READ_TIMEOUT_2026.environmentVariable(), params.envVar);
env.set(SdkSystemSetting.AWS_ENABLE_DEFAULT_SOCKET_TIMEOUT_2026.environmentVariable(), params.envVar);
}

EnableDefaultReadTimeout2026Resolver resolver =
new EnableDefaultReadTimeout2026Resolver().defaultEnableReadTimeout2026(params.defaultEnableReadTimeout2026);
EnableDefaultSocketTimeout2026Resolver resolver =
new EnableDefaultSocketTimeout2026Resolver().defaultEnableSocketTimeout2026(params.defaultEnableSocketTimeout2026);

assertThat(resolver.resolve()).isEqualTo(params.expected);
});
Expand All @@ -83,19 +83,19 @@ private static Stream<TestParams> params() {
new TestParams().expected(false),

// precedence testing
new TestParams().systemProperty("true").defaultEnableReadTimeout2026(true).expected(true),
new TestParams().systemProperty("false").defaultEnableReadTimeout2026(true).expected(false),
new TestParams().envVar("true").defaultEnableReadTimeout2026(true).expected(true),
new TestParams().envVar("false").defaultEnableReadTimeout2026(true).expected(false),
new TestParams().defaultEnableReadTimeout2026(true).expected(true),
new TestParams().defaultEnableReadTimeout2026(false).expected(false)
new TestParams().systemProperty("true").defaultEnableSocketTimeout2026(true).expected(true),
new TestParams().systemProperty("false").defaultEnableSocketTimeout2026(true).expected(false),
new TestParams().envVar("true").defaultEnableSocketTimeout2026(true).expected(true),
new TestParams().envVar("false").defaultEnableSocketTimeout2026(true).expected(false),
new TestParams().defaultEnableSocketTimeout2026(true).expected(true),
new TestParams().defaultEnableSocketTimeout2026(false).expected(false)
);
}

private static class TestParams {
private String systemProperty;
private String envVar;
private Boolean defaultEnableReadTimeout2026;
private Boolean defaultEnableSocketTimeout2026;
private boolean expected;

public TestParams systemProperty(String systemProperty) {
Expand All @@ -108,8 +108,8 @@ public TestParams envVar(String envVar) {
return this;
}

public TestParams defaultEnableReadTimeout2026(Boolean defaultEnableReadTimeout2026) {
this.defaultEnableReadTimeout2026 = defaultEnableReadTimeout2026;
public TestParams defaultEnableSocketTimeout2026(Boolean defaultEnableSocketTimeout2026) {
this.defaultEnableSocketTimeout2026 = defaultEnableSocketTimeout2026;
return this;
}

Expand Down
Loading