From ac0c45e5b9af81c9bd82b84154b60289f573fbfd Mon Sep 17 00:00:00 2001 From: Dongie Agnir Date: Fri, 28 Aug 2020 12:10:00 -0700 Subject: [PATCH] Revert "Updated endpoint discovery behavior for operations that require endpoint discovery." This reverts commit c2c0e28d72c7d6abfd262f98f87136e6da18a933. --- .../customization/CustomizationConfig.java | 17 -- .../codegen/poet/client/AsyncClientClass.java | 42 +--- .../codegen/poet/client/SyncClientClass.java | 50 +--- .../client/test-endpoint-discovery-async.java | 28 +-- .../client/test-endpoint-discovery-sync.java | 31 +-- .../poet/client/test-json-client-class.java | 3 - .../poet/client/test-query-client-class.java | 3 - .../builder/SdkDefaultClientBuilder.java | 5 - .../config/SdkAdvancedClientOption.java | 1 + .../SdkInternalTestAdvancedClientOption.java | 46 ---- .../customization.config | 3 - .../service-2.json | 113 --------- .../endpointdiscoveryrequired/service-2.json | 113 --------- ...pointDiscoveryAndEndpointOverrideTest.java | 231 ------------------ .../services/EndpointDiscoveryTest.java | 11 +- 15 files changed, 13 insertions(+), 684 deletions(-) delete mode 100644 core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/SdkInternalTestAdvancedClientOption.java delete mode 100644 test/codegen-generated-classes-test/src/main/resources/codegen-resources/endpointdiscoveryrequired-withcustomization/customization.config delete mode 100644 test/codegen-generated-classes-test/src/main/resources/codegen-resources/endpointdiscoveryrequired-withcustomization/service-2.json delete mode 100644 test/codegen-generated-classes-test/src/main/resources/codegen-resources/endpointdiscoveryrequired/service-2.json delete mode 100644 test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/EndpointDiscoveryAndEndpointOverrideTest.java diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/model/config/customization/CustomizationConfig.java b/codegen/src/main/java/software/amazon/awssdk/codegen/model/config/customization/CustomizationConfig.java index 5146ab82d9f5..8b2230310c46 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/model/config/customization/CustomizationConfig.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/model/config/customization/CustomizationConfig.java @@ -165,13 +165,6 @@ public class CustomizationConfig { */ private boolean enableEndpointDiscoveryMethodRequired = false; - /** - * Allow a customer to set an endpoint override AND bypass endpoint discovery on their client even when endpoint discovery - * enabled is true and endpoint discovery is required for an operation. This customization should almost never be "true" - * because it creates a confusing customer experience. - */ - private boolean allowEndpointOverrideForEndpointDiscoveryRequiredOperations = false; - private CustomizationConfig() { } @@ -427,14 +420,4 @@ public boolean isEnableEndpointDiscoveryMethodRequired() { public void setEnableEndpointDiscoveryMethodRequired(boolean enableEndpointDiscoveryMethodRequired) { this.enableEndpointDiscoveryMethodRequired = enableEndpointDiscoveryMethodRequired; } - - public boolean allowEndpointOverrideForEndpointDiscoveryRequiredOperations() { - return allowEndpointOverrideForEndpointDiscoveryRequiredOperations; - } - - public void setAllowEndpointOverrideForEndpointDiscoveryRequiredOperations( - boolean allowEndpointOverrideForEndpointDiscoveryRequiredOperations) { - this.allowEndpointOverrideForEndpointDiscoveryRequiredOperations = - allowEndpointOverrideForEndpointDiscoveryRequiredOperations; - } } diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java index 27443913d10d..13ac033c3617 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/AsyncClientClass.java @@ -166,17 +166,6 @@ private MethodSpec constructor(Builder classBuilder) { EndpointDiscoveryRefreshCache.class, poetExtensions.getClientClass(model.getNamingStrategy().getServiceName() + "AsyncEndpointDiscoveryCacheLoader")); - - if (model.getCustomizationConfig().allowEndpointOverrideForEndpointDiscoveryRequiredOperations()) { - builder.beginControlFlow("if (clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == " - + "Boolean.TRUE)"); - builder.addStatement("log.warn($S)", - "Endpoint discovery is enabled for this client, and an endpoint override was also " - + "specified. This will disable endpoint discovery for methods that require it, instead " - + "using the specified endpoint override. This may or may not be what you intended."); - builder.endControlFlow(); - } - builder.endControlFlow(); } @@ -231,37 +220,8 @@ protected MethodSpec.Builder operationBody(MethodSpec.Builder builder, Operation builder.addCode(eventToByteBufferPublisher(opModel)); if (opModel.getEndpointDiscovery() != null) { - builder.addStatement("boolean endpointDiscoveryEnabled = " - + "clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED)"); - builder.addStatement("boolean endpointOverridden = " - + "clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE"); - - if (opModel.getEndpointDiscovery().isRequired()) { - if (!model.getCustomizationConfig().allowEndpointOverrideForEndpointDiscoveryRequiredOperations()) { - builder.beginControlFlow("if (endpointOverridden)"); - builder.addStatement("throw new $T($S)", IllegalStateException.class, - "This operation requires endpoint discovery, but an endpoint override was specified " - + "when the client was created. This is not supported."); - builder.endControlFlow(); - - builder.beginControlFlow("if (!endpointDiscoveryEnabled)"); - builder.addStatement("throw new $T($S)", IllegalStateException.class, - "This operation requires endpoint discovery, but endpoint discovery was disabled on the " - + "client."); - builder.endControlFlow(); - } else { - builder.beginControlFlow("if (endpointOverridden)"); - builder.addStatement("endpointDiscoveryEnabled = false"); - builder.nextControlFlow("else if (!endpointDiscoveryEnabled)"); - builder.addStatement("throw new $T($S)", IllegalStateException.class, - "This operation requires endpoint discovery to be enabled, or for you to specify an " - + "endpoint override when the client is created."); - builder.endControlFlow(); - } - } - builder.addStatement("$T cachedEndpoint = null", URI.class); - builder.beginControlFlow("if (endpointDiscoveryEnabled)"); + builder.beginControlFlow("if (clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED))"); builder.addStatement("\n\nString key = clientConfiguration.option($T.CREDENTIALS_PROVIDER).resolveCredentials()" + ".accessKeyId()", AwsClientOption.class); builder.addStatement("EndpointDiscoveryRequest endpointDiscoveryRequest = $T.builder().required($L)" + diff --git a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/SyncClientClass.java b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/SyncClientClass.java index bff7d7e92a92..d1e8d569475f 100644 --- a/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/SyncClientClass.java +++ b/codegen/src/main/java/software/amazon/awssdk/codegen/poet/client/SyncClientClass.java @@ -60,7 +60,6 @@ import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; -import software.amazon.awssdk.utils.Logger; //TODO Make SyncClientClass extend SyncClientInterface (similar to what we do in AsyncClientClass) public class SyncClientClass implements ClassSpec { @@ -87,7 +86,6 @@ public TypeSpec poetSpec() { .addSuperinterface(interfaceClass) .addJavadoc("Internal implementation of {@link $1T}.\n\n@see $1T#builder()", interfaceClass) - .addField(logger()) .addField(SyncClientHandler.class, "clientHandler", PRIVATE, FINAL) .addField(protocolSpec.protocolFactory(model)) .addField(SdkClientConfiguration.class, "clientConfiguration", PRIVATE, FINAL) @@ -121,12 +119,6 @@ public TypeSpec poetSpec() { return classBuilder.build(); } - private FieldSpec logger() { - return FieldSpec.builder(Logger.class, "log", PRIVATE, STATIC, FINAL) - .initializer("$T.loggerFor($T.class)", Logger.class, className) - .build(); - } - private MethodSpec nameMethod() { return MethodSpec.methodBuilder("serviceName") .addAnnotation(Override.class) @@ -162,17 +154,6 @@ private MethodSpec constructor() { EndpointDiscoveryRefreshCache.class, poetExtensions.getClientClass(model.getNamingStrategy().getServiceName() + "EndpointDiscoveryCacheLoader")); - - if (model.getCustomizationConfig().allowEndpointOverrideForEndpointDiscoveryRequiredOperations()) { - builder.beginControlFlow("if (clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == " - + "Boolean.TRUE)"); - builder.addStatement("log.warn(() -> $S)", - "Endpoint discovery is enabled for this client, and an endpoint override was also " - + "specified. This will disable endpoint discovery for methods that require it, instead " - + "using the specified endpoint override. This may or may not be what you intended."); - builder.endControlFlow(); - } - builder.endControlFlow(); } @@ -200,37 +181,8 @@ private List operationMethodSpecs(OperationModel opModel) { protocolSpec.errorResponseHandler(opModel).ifPresent(method::addCode); if (opModel.getEndpointDiscovery() != null) { - method.addStatement("boolean endpointDiscoveryEnabled = " - + "clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED)"); - method.addStatement("boolean endpointOverridden = " - + "clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE"); - - if (opModel.getEndpointDiscovery().isRequired()) { - if (!model.getCustomizationConfig().allowEndpointOverrideForEndpointDiscoveryRequiredOperations()) { - method.beginControlFlow("if (endpointOverridden)"); - method.addStatement("throw new $T($S)", IllegalStateException.class, - "This operation requires endpoint discovery, but an endpoint override was specified " - + "when the client was created. This is not supported."); - method.endControlFlow(); - - method.beginControlFlow("if (!endpointDiscoveryEnabled)"); - method.addStatement("throw new $T($S)", IllegalStateException.class, - "This operation requires endpoint discovery, but endpoint discovery was disabled on the " - + "client."); - method.endControlFlow(); - } else { - method.beginControlFlow("if (endpointOverridden)"); - method.addStatement("endpointDiscoveryEnabled = false"); - method.nextControlFlow("else if (!endpointDiscoveryEnabled)"); - method.addStatement("throw new $T($S)", IllegalStateException.class, - "This operation requires endpoint discovery to be enabled, or for you to specify an " - + "endpoint override when the client is created."); - method.endControlFlow(); - } - } - method.addStatement("$T cachedEndpoint = null", URI.class); - method.beginControlFlow("if (endpointDiscoveryEnabled)"); + method.beginControlFlow("if (clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED))"); method.addStatement("\n\nString key = clientConfiguration.option($T.CREDENTIALS_PROVIDER)." + "resolveCredentials().accessKeyId()", AwsClientOption.class); method.addStatement("EndpointDiscoveryRequest endpointDiscoveryRequest = $T.builder().required($L)" + diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-async.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-async.java index edf28f14c1d9..10e45085470f 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-async.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-async.java @@ -167,18 +167,8 @@ public CompletableFuture testDiscovery HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); - boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED); - boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE; - if (endpointOverridden) { - throw new IllegalStateException( - "This operation requires endpoint discovery, but an endpoint override was specified when the client was created. This is not supported."); - } - if (!endpointDiscoveryEnabled) { - throw new IllegalStateException( - "This operation requires endpoint discovery, but endpoint discovery was disabled on the client."); - } URI cachedEndpoint = null; - if (endpointDiscoveryEnabled) { + if (clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED)) { String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId(); EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true) @@ -241,10 +231,8 @@ public CompletableFuture testDiscoveryOptional( HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); - boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED); - boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE; URI cachedEndpoint = null; - if (endpointDiscoveryEnabled) { + if (clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED)) { String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId(); EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(false) @@ -307,18 +295,8 @@ public CompletableFuture testDiscoveryRequired( HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); - boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED); - boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE; - if (endpointOverridden) { - throw new IllegalStateException( - "This operation requires endpoint discovery, but an endpoint override was specified when the client was created. This is not supported."); - } - if (!endpointDiscoveryEnabled) { - throw new IllegalStateException( - "This operation requires endpoint discovery, but endpoint discovery was disabled on the client."); - } URI cachedEndpoint = null; - if (endpointDiscoveryEnabled) { + if (clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED)) { String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId(); EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true) diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-sync.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-sync.java index 2a8faa80e18f..e87c377e9dc1 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-sync.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-sync.java @@ -38,7 +38,6 @@ import software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryIdentifiersRequiredRequestMarshaller; import software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryOptionalRequestMarshaller; import software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryRequiredRequestMarshaller; -import software.amazon.awssdk.utils.Logger; /** * Internal implementation of {@link EndpointDiscoveryTestClient}. @@ -48,8 +47,6 @@ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultEndpointDiscoveryTestClient implements EndpointDiscoveryTestClient { - private static final Logger log = Logger.loggerFor(DefaultEndpointDiscoveryTestClient.class); - private final SyncClientHandler clientHandler; private final AwsJsonProtocolFactory protocolFactory; @@ -142,18 +139,8 @@ public TestDiscoveryIdentifiersRequiredResponse testDiscoveryIdentifiersRequired HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); - boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED); - boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE; - if (endpointOverridden) { - throw new IllegalStateException( - "This operation requires endpoint discovery, but an endpoint override was specified when the client was created. This is not supported."); - } - if (!endpointDiscoveryEnabled) { - throw new IllegalStateException( - "This operation requires endpoint discovery, but endpoint discovery was disabled on the client."); - } URI cachedEndpoint = null; - if (endpointDiscoveryEnabled) { + if (clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED)) { String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId(); EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true) @@ -204,10 +191,8 @@ public TestDiscoveryOptionalResponse testDiscoveryOptional(TestDiscoveryOptional HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); - boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED); - boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE; URI cachedEndpoint = null; - if (endpointDiscoveryEnabled) { + if (clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED)) { String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId(); EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(false) @@ -257,18 +242,8 @@ public TestDiscoveryRequiredResponse testDiscoveryRequired(TestDiscoveryRequired HttpResponseHandler errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); - boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED); - boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE; - if (endpointOverridden) { - throw new IllegalStateException( - "This operation requires endpoint discovery, but an endpoint override was specified when the client was created. This is not supported."); - } - if (!endpointDiscoveryEnabled) { - throw new IllegalStateException( - "This operation requires endpoint discovery, but endpoint discovery was disabled on the client."); - } URI cachedEndpoint = null; - if (endpointDiscoveryEnabled) { + if (clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED)) { String key = clientConfiguration.option(AwsClientOption.CREDENTIALS_PROVIDER).resolveCredentials().accessKeyId(); EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true) diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-class.java index 0fc88ac35dd9..569ed383c88e 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-class.java @@ -60,7 +60,6 @@ import software.amazon.awssdk.services.json.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingInputOutputOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingOutputOperationRequestMarshaller; -import software.amazon.awssdk.utils.Logger; import software.amazon.awssdk.utils.Validate; /** @@ -71,8 +70,6 @@ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultJsonClient implements JsonClient { - private static final Logger log = Logger.loggerFor(DefaultJsonClient.class); - private final SyncClientHandler clientHandler; private final AwsJsonProtocolFactory protocolFactory; diff --git a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-client-class.java b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-client-class.java index dd32d0e83044..c4526fc54be0 100644 --- a/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-client-class.java +++ b/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-client-class.java @@ -36,7 +36,6 @@ import software.amazon.awssdk.services.query.transform.APostOperationWithOutputRequestMarshaller; import software.amazon.awssdk.services.query.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.query.transform.StreamingOutputOperationRequestMarshaller; -import software.amazon.awssdk.utils.Logger; /** * Internal implementation of {@link QueryClient}. @@ -46,8 +45,6 @@ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultQueryClient implements QueryClient { - private static final Logger log = Logger.loggerFor(DefaultQueryClient.class); - private final SyncClientHandler clientHandler; private final AwsQueryProtocolFactory protocolFactory; diff --git a/core/sdk-core/src/main/java/software/amazon/awssdk/core/client/builder/SdkDefaultClientBuilder.java b/core/sdk-core/src/main/java/software/amazon/awssdk/core/client/builder/SdkDefaultClientBuilder.java index 1628c97cdd59..6725771e737b 100644 --- a/core/sdk-core/src/main/java/software/amazon/awssdk/core/client/builder/SdkDefaultClientBuilder.java +++ b/core/sdk-core/src/main/java/software/amazon/awssdk/core/client/builder/SdkDefaultClientBuilder.java @@ -27,14 +27,12 @@ import static software.amazon.awssdk.core.client.config.SdkClientOption.API_CALL_TIMEOUT; import static software.amazon.awssdk.core.client.config.SdkClientOption.ASYNC_HTTP_CLIENT; import static software.amazon.awssdk.core.client.config.SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED; -import static software.amazon.awssdk.core.client.config.SdkClientOption.ENDPOINT_OVERRIDDEN; import static software.amazon.awssdk.core.client.config.SdkClientOption.EXECUTION_INTERCEPTORS; import static software.amazon.awssdk.core.client.config.SdkClientOption.METRIC_PUBLISHERS; import static software.amazon.awssdk.core.client.config.SdkClientOption.PROFILE_FILE; import static software.amazon.awssdk.core.client.config.SdkClientOption.PROFILE_NAME; import static software.amazon.awssdk.core.client.config.SdkClientOption.RETRY_POLICY; import static software.amazon.awssdk.core.client.config.SdkClientOption.SCHEDULED_EXECUTOR_SERVICE; -import static software.amazon.awssdk.core.internal.SdkInternalTestAdvancedClientOption.ENDPOINT_OVERRIDDEN_OVERRIDE; import static software.amazon.awssdk.utils.CollectionUtils.mergeLists; import static software.amazon.awssdk.utils.Validate.paramNotNull; @@ -369,9 +367,6 @@ public final B overrideConfiguration(ClientOverrideConfiguration overrideConfig) clientConfiguration.option(PROFILE_FILE, overrideConfig.defaultProfileFile().orElse(null)); clientConfiguration.option(PROFILE_NAME, overrideConfig.defaultProfileName().orElse(null)); clientConfiguration.option(METRIC_PUBLISHERS, overrideConfig.metricPublishers()); - overrideConfig.advancedOption(ENDPOINT_OVERRIDDEN_OVERRIDE).ifPresent(value -> { - clientConfiguration.option(ENDPOINT_OVERRIDDEN, value); - }); return thisBuilder(); } diff --git a/core/sdk-core/src/main/java/software/amazon/awssdk/core/client/config/SdkAdvancedClientOption.java b/core/sdk-core/src/main/java/software/amazon/awssdk/core/client/config/SdkAdvancedClientOption.java index 8676ba5bcb49..e4b819ddd2a0 100644 --- a/core/sdk-core/src/main/java/software/amazon/awssdk/core/client/config/SdkAdvancedClientOption.java +++ b/core/sdk-core/src/main/java/software/amazon/awssdk/core/client/config/SdkAdvancedClientOption.java @@ -45,6 +45,7 @@ public class SdkAdvancedClientOption extends ClientOption { */ public static final SdkAdvancedClientOption SIGNER = new SdkAdvancedClientOption<>(Signer.class); + /** * SDK uses endpoint trait and hostPrefix trait specified in service model to modify * the endpoint host that the API request is sent to. diff --git a/core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/SdkInternalTestAdvancedClientOption.java b/core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/SdkInternalTestAdvancedClientOption.java deleted file mode 100644 index 9bebbe2fd600..000000000000 --- a/core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/SdkInternalTestAdvancedClientOption.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.internal; - -import java.net.URI; -import software.amazon.awssdk.annotations.SdkInternalApi; -import software.amazon.awssdk.annotations.SdkTestInternalApi; -import software.amazon.awssdk.core.client.builder.SdkClientBuilder; -import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption; -import software.amazon.awssdk.core.client.config.SdkClientOption; - -/** - * Options of {@link SdkAdvancedClientOption} that must not be used outside of tests that are stored in this project. - * Changes to this class are not guaranteed to be backwards compatible. - */ -@SdkInternalApi -public class SdkInternalTestAdvancedClientOption extends SdkAdvancedClientOption { - /** - * By default, the SDK handles endpoints specified via {@link SdkClientBuilder#endpointOverride(URI)} differently than - * endpoints generated from a specific region. For example, endpoint discovery is not supported in some cases when endpoint - * overrides are used. - * - * When this option is set, the {@link SdkClientOption#ENDPOINT_OVERRIDDEN} is forced to this value. Because of the way this - * is implemented, the client configuration must be configured *after* the {@code endpointOverride} is configured. - */ - @SdkTestInternalApi - public static final SdkInternalTestAdvancedClientOption ENDPOINT_OVERRIDDEN_OVERRIDE = - new SdkInternalTestAdvancedClientOption<>(Boolean.class); - - protected SdkInternalTestAdvancedClientOption(Class valueClass) { - super(valueClass); - } -} diff --git a/test/codegen-generated-classes-test/src/main/resources/codegen-resources/endpointdiscoveryrequired-withcustomization/customization.config b/test/codegen-generated-classes-test/src/main/resources/codegen-resources/endpointdiscoveryrequired-withcustomization/customization.config deleted file mode 100644 index 8175efc28858..000000000000 --- a/test/codegen-generated-classes-test/src/main/resources/codegen-resources/endpointdiscoveryrequired-withcustomization/customization.config +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowEndpointOverrideForEndpointDiscoveryRequiredOperations": true -} \ No newline at end of file diff --git a/test/codegen-generated-classes-test/src/main/resources/codegen-resources/endpointdiscoveryrequired-withcustomization/service-2.json b/test/codegen-generated-classes-test/src/main/resources/codegen-resources/endpointdiscoveryrequired-withcustomization/service-2.json deleted file mode 100644 index 1adcc3ac2d95..000000000000 --- a/test/codegen-generated-classes-test/src/main/resources/codegen-resources/endpointdiscoveryrequired-withcustomization/service-2.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "version":"2.0", - "metadata":{ - "apiVersion":"2018-08-31", - "endpointPrefix":"awsendpointdiscoveryrequiredwithcustomizationtestservice", - "jsonVersion":"1.1", - "protocol":"json", - "serviceAbbreviation":"AwsEndpointDiscoveryRequiredWithCustomizationTest", - "serviceFullName":"AwsEndpointDiscoveryRequiredWithCustomizationTest", - "serviceId":"AwsEndpointDiscoveryRequiredWithCustomizationTest", - "signatureVersion":"v4", - "signingName":"awsendpointdiscoveryrequiredtestwithcustomizationservice", - "targetPrefix":"AwsEndpointDiscoveryRequiredWithCustomizationTestService" - }, - "operations":{ - "DescribeEndpoints":{ - "name":"DescribeEndpoints", - "http":{ - "method":"POST", - "requestUri":"/DescribeEndpoints" - }, - "input":{"shape":"DescribeEndpointsRequest"}, - "output":{"shape":"DescribeEndpointsResponse"}, - "endpointoperation":true - }, - "TestDiscoveryIdentifiersRequired":{ - "name":"TestDiscoveryIdentifiersRequired", - "http":{ - "method":"POST", - "requestUri":"/" - }, - "input":{"shape":"TestDiscoveryIdentifiersRequiredRequest"}, - "output":{"shape":"TestDiscoveryIdentifiersRequiredResponse"}, - "endpointdiscovery":{"required":true} - }, - "TestDiscoveryRequired":{ - "name":"TestDiscoveryRequired", - "http":{ - "method":"POST", - "requestUri":"/TestDiscoveryRequired" - }, - "input":{"shape":"TestDiscoveryRequiredRequest"}, - "output":{"shape":"TestDiscoveryRequiredResponse"}, - "endpointdiscovery":{"required":true} - } - }, - "shapes":{ - "Boolean":{"type":"boolean"}, - "DescribeEndpointsRequest":{ - "type":"structure", - "members":{ - "Operation":{"shape":"String"}, - "Identifiers":{"shape":"Identifiers"} - } - }, - "DescribeEndpointsResponse":{ - "type":"structure", - "required":["Endpoints"], - "members":{ - "Endpoints":{"shape":"Endpoints"} - } - }, - "Endpoint":{ - "type":"structure", - "required":[ - "Address", - "CachePeriodInMinutes" - ], - "members":{ - "Address":{"shape":"String"}, - "CachePeriodInMinutes":{"shape":"Long"} - } - }, - "Endpoints":{ - "type":"list", - "member":{"shape":"Endpoint"} - }, - "Identifiers":{ - "type":"map", - "key":{"shape":"String"}, - "value":{"shape":"String"} - }, - "Long":{"type":"long"}, - "String":{"type":"string"}, - "TestDiscoveryIdentifiersRequiredRequest":{ - "type":"structure", - "required":["Sdk"], - "members":{ - "Sdk":{ - "shape":"String", - "endpointdiscoveryid":true - } - } - }, - "TestDiscoveryIdentifiersRequiredResponse":{ - "type":"structure", - "members":{ - "DiscoveredEndpoint":{"shape":"Boolean"} - } - }, - "TestDiscoveryRequiredRequest":{ - "type":"structure", - "members":{ - } - }, - "TestDiscoveryRequiredResponse":{ - "type":"structure", - "members":{ - "DiscoveredEndpoint":{"shape":"Boolean"} - } - } - } -} \ No newline at end of file diff --git a/test/codegen-generated-classes-test/src/main/resources/codegen-resources/endpointdiscoveryrequired/service-2.json b/test/codegen-generated-classes-test/src/main/resources/codegen-resources/endpointdiscoveryrequired/service-2.json deleted file mode 100644 index 580005251e25..000000000000 --- a/test/codegen-generated-classes-test/src/main/resources/codegen-resources/endpointdiscoveryrequired/service-2.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "version":"2.0", - "metadata":{ - "apiVersion":"2018-08-31", - "endpointPrefix":"awsendpointdiscoveryrequiredtestservice", - "jsonVersion":"1.1", - "protocol":"json", - "serviceAbbreviation":"AwsEndpointDiscoveryRequiredTest", - "serviceFullName":"AwsEndpointDiscoveryRequiredTest", - "serviceId":"AwsEndpointDiscoveryRequiredTest", - "signatureVersion":"v4", - "signingName":"awsendpointdiscoveryrequiredtestservice", - "targetPrefix":"AwsEndpointDiscoveryRequiredTestService" - }, - "operations":{ - "DescribeEndpoints":{ - "name":"DescribeEndpoints", - "http":{ - "method":"POST", - "requestUri":"/DescribeEndpoints" - }, - "input":{"shape":"DescribeEndpointsRequest"}, - "output":{"shape":"DescribeEndpointsResponse"}, - "endpointoperation":true - }, - "TestDiscoveryIdentifiersRequired":{ - "name":"TestDiscoveryIdentifiersRequired", - "http":{ - "method":"POST", - "requestUri":"/" - }, - "input":{"shape":"TestDiscoveryIdentifiersRequiredRequest"}, - "output":{"shape":"TestDiscoveryIdentifiersRequiredResponse"}, - "endpointdiscovery":{"required":true} - }, - "TestDiscoveryRequired":{ - "name":"TestDiscoveryRequired", - "http":{ - "method":"POST", - "requestUri":"/TestDiscoveryRequired" - }, - "input":{"shape":"TestDiscoveryRequiredRequest"}, - "output":{"shape":"TestDiscoveryRequiredResponse"}, - "endpointdiscovery":{"required":true} - } - }, - "shapes":{ - "Boolean":{"type":"boolean"}, - "DescribeEndpointsRequest":{ - "type":"structure", - "members":{ - "Operation":{"shape":"String"}, - "Identifiers":{"shape":"Identifiers"} - } - }, - "DescribeEndpointsResponse":{ - "type":"structure", - "required":["Endpoints"], - "members":{ - "Endpoints":{"shape":"Endpoints"} - } - }, - "Endpoint":{ - "type":"structure", - "required":[ - "Address", - "CachePeriodInMinutes" - ], - "members":{ - "Address":{"shape":"String"}, - "CachePeriodInMinutes":{"shape":"Long"} - } - }, - "Endpoints":{ - "type":"list", - "member":{"shape":"Endpoint"} - }, - "Identifiers":{ - "type":"map", - "key":{"shape":"String"}, - "value":{"shape":"String"} - }, - "Long":{"type":"long"}, - "String":{"type":"string"}, - "TestDiscoveryIdentifiersRequiredRequest":{ - "type":"structure", - "required":["Sdk"], - "members":{ - "Sdk":{ - "shape":"String", - "endpointdiscoveryid":true - } - } - }, - "TestDiscoveryIdentifiersRequiredResponse":{ - "type":"structure", - "members":{ - "DiscoveredEndpoint":{"shape":"Boolean"} - } - }, - "TestDiscoveryRequiredRequest":{ - "type":"structure", - "members":{ - } - }, - "TestDiscoveryRequiredResponse":{ - "type":"structure", - "members":{ - "DiscoveredEndpoint":{"shape":"Boolean"} - } - } - } -} \ No newline at end of file diff --git a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/EndpointDiscoveryAndEndpointOverrideTest.java b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/EndpointDiscoveryAndEndpointOverrideTest.java deleted file mode 100644 index c58b2fdbbf79..000000000000 --- a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/EndpointDiscoveryAndEndpointOverrideTest.java +++ /dev/null @@ -1,231 +0,0 @@ -package software.amazon.awssdk.services; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.net.URI; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.CompletionException; -import java.util.function.Consumer; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import software.amazon.awssdk.core.client.builder.SdkClientBuilder; -import software.amazon.awssdk.core.exception.SdkClientException; -import software.amazon.awssdk.core.interceptor.Context; -import software.amazon.awssdk.core.interceptor.ExecutionAttributes; -import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; -import software.amazon.awssdk.services.endpointdiscoveryrequiredtest.EndpointDiscoveryRequiredTestAsyncClient; -import software.amazon.awssdk.services.endpointdiscoveryrequiredtest.EndpointDiscoveryRequiredTestClient; -import software.amazon.awssdk.services.endpointdiscoveryrequiredwithcustomizationtest.EndpointDiscoveryRequiredWithCustomizationTestAsyncClient; -import software.amazon.awssdk.services.endpointdiscoveryrequiredwithcustomizationtest.EndpointDiscoveryRequiredWithCustomizationTestClient; -import software.amazon.awssdk.services.endpointdiscoverytest.EndpointDiscoveryTestAsyncClient; -import software.amazon.awssdk.services.endpointdiscoverytest.EndpointDiscoveryTestClient; - -/** - * Verify the behavior of endpoint discovery when combined with endpoint override configuration. - */ -@RunWith(Parameterized.class) -public class EndpointDiscoveryAndEndpointOverrideTest { - private static final String OPTIONAL_SERVICE_ENDPOINT = "https://awsendpointdiscoverytestservice.us-west-2.amazonaws.com"; - private static final String REQUIRED_SERVICE_ENDPOINT = "https://awsendpointdiscoveryrequiredtestservice.us-west-2.amazonaws.com"; - private static final String REQUIRED_CUSTOMIZED_SERVICE_ENDPOINT = "https://awsendpointdiscoveryrequiredwithcustomizationtestservice.us-west-2.amazonaws.com"; - private static final String ENDPOINT_OVERRIDE = "https://endpointoverride"; - - private static final List> ALL_TEST_CASES = new ArrayList<>(); - - private final TestCase testCase; - - static { - // This first case (case 0/1) is different than other SDKs/the SEP. This should probably actually throw an exception. - ALL_TEST_CASES.addAll(endpointDiscoveryOptionalCases(true, true, ENDPOINT_OVERRIDE + "/DescribeEndpoints", ENDPOINT_OVERRIDE + "/TestDiscoveryOptional")); - ALL_TEST_CASES.addAll(endpointDiscoveryOptionalCases(true, false, OPTIONAL_SERVICE_ENDPOINT + "/DescribeEndpoints", OPTIONAL_SERVICE_ENDPOINT + "/TestDiscoveryOptional")); - ALL_TEST_CASES.addAll(endpointDiscoveryOptionalCases(false, true, ENDPOINT_OVERRIDE + "/TestDiscoveryOptional")); - ALL_TEST_CASES.addAll(endpointDiscoveryOptionalCases(false, false, OPTIONAL_SERVICE_ENDPOINT + "/TestDiscoveryOptional")); - - ALL_TEST_CASES.addAll(endpointDiscoveryRequiredCases(true, true)); - ALL_TEST_CASES.addAll(endpointDiscoveryRequiredCases(true, false, REQUIRED_SERVICE_ENDPOINT + "/DescribeEndpoints")); - ALL_TEST_CASES.addAll(endpointDiscoveryRequiredCases(false, true)); - ALL_TEST_CASES.addAll(endpointDiscoveryRequiredCases(false, false)); - - // These cases are different from what one would expect. Even though endpoint discovery is required (based on the model), - // if the customer specifies an endpoint override AND the service is customized, we actually bypass endpoint discovery. - ALL_TEST_CASES.addAll(endpointDiscoveryRequiredAndCustomizedCases(true, true, ENDPOINT_OVERRIDE + "/TestDiscoveryRequired")); - ALL_TEST_CASES.addAll(endpointDiscoveryRequiredAndCustomizedCases(true, false, REQUIRED_CUSTOMIZED_SERVICE_ENDPOINT + "/DescribeEndpoints")); - ALL_TEST_CASES.addAll(endpointDiscoveryRequiredAndCustomizedCases(false, true, ENDPOINT_OVERRIDE + "/TestDiscoveryRequired")); - ALL_TEST_CASES.addAll(endpointDiscoveryRequiredAndCustomizedCases(false, false)); - } - - public EndpointDiscoveryAndEndpointOverrideTest(TestCase testCase) { - this.testCase = testCase; - } - - @Before - public void reset() { - EndpointCapturingInterceptor.reset(); - } - - @Parameterized.Parameters(name = "{index} - {0}") - public static List> testCases() { - return ALL_TEST_CASES; - } - - @Test(timeout = 5_000) - public void invokeTestCase() { - try { - testCase.callClient(); - Assert.fail(); - } catch (Throwable e) { - // Unwrap async exceptions so that they can be tested the same as async ones. - if (e instanceof CompletionException) { - e = e.getCause(); - } - - if (testCase.expectedPaths.length > 0) { - // We're using fake endpoints, so we expect even "valid" requests to fail because of unknown host exceptions. - assertThat(e.getCause()).hasRootCauseInstanceOf(UnknownHostException.class); - } else { - // If the requests are not expected to go through, we expect to see illegal state exceptions because the - // client is configured incorrectly. - assertThat(e).isInstanceOf(IllegalStateException.class); - } - } - - if (testCase.enforcePathOrder) { - assertThat(EndpointCapturingInterceptor.ENDPOINTS).containsExactly(testCase.expectedPaths); - } else { - // Async is involved when order doesn't matter, so wait a little while until the expected number of paths arrive. - while (EndpointCapturingInterceptor.ENDPOINTS.size() < testCase.expectedPaths.length) { - Thread.yield(); - } - assertThat(EndpointCapturingInterceptor.ENDPOINTS).containsExactlyInAnyOrder(testCase.expectedPaths); - } - } - - private static List> endpointDiscoveryOptionalCases(boolean endpointDiscoveryEnabled, - boolean endpointOverridden, - String... expectedEndpoints) { - TestCase syncCase = new TestCase<>(createClient(EndpointDiscoveryTestClient.builder().endpointDiscoveryEnabled(endpointDiscoveryEnabled), - endpointOverridden), - c -> c.testDiscoveryOptional(r -> {}), - caseName(EndpointDiscoveryTestClient.class, endpointDiscoveryEnabled, endpointOverridden, expectedEndpoints), - false, - expectedEndpoints); - - TestCase asyncCase = new TestCase<>(createClient(EndpointDiscoveryTestAsyncClient.builder().endpointDiscoveryEnabled(endpointDiscoveryEnabled), - endpointOverridden), - c -> c.testDiscoveryOptional(r -> {}).join(), - caseName(EndpointDiscoveryTestAsyncClient.class, endpointDiscoveryEnabled, endpointOverridden, expectedEndpoints), - false, - expectedEndpoints); - - return Arrays.asList(syncCase, asyncCase); - } - - private static List> endpointDiscoveryRequiredCases(boolean endpointDiscoveryEnabled, - boolean endpointOverridden, - String... expectedEndpoints) { - TestCase syncCase = new TestCase<>(createClient(EndpointDiscoveryRequiredTestClient.builder().endpointDiscoveryEnabled(endpointDiscoveryEnabled), - endpointOverridden), - c -> c.testDiscoveryRequired(r -> {}), - caseName(EndpointDiscoveryRequiredTestClient.class, endpointDiscoveryEnabled, endpointOverridden, expectedEndpoints), - true, - expectedEndpoints); - - TestCase asyncCase = new TestCase<>(createClient(EndpointDiscoveryRequiredTestAsyncClient.builder().endpointDiscoveryEnabled(endpointDiscoveryEnabled), - endpointOverridden), - c -> c.testDiscoveryRequired(r -> {}).join(), - caseName(EndpointDiscoveryRequiredTestAsyncClient.class, endpointDiscoveryEnabled, endpointOverridden, expectedEndpoints), - true, - expectedEndpoints); - - return Arrays.asList(syncCase, asyncCase); - } - - private static List> endpointDiscoveryRequiredAndCustomizedCases(boolean endpointDiscoveryEnabled, - boolean endpointOverridden, - String... expectedEndpoints) { - TestCase syncCase = new TestCase<>(createClient(EndpointDiscoveryRequiredWithCustomizationTestClient.builder().endpointDiscoveryEnabled(endpointDiscoveryEnabled), - endpointOverridden), - c -> c.testDiscoveryRequired(r -> {}), - caseName(EndpointDiscoveryRequiredWithCustomizationTestClient.class, endpointDiscoveryEnabled, endpointOverridden, expectedEndpoints), - true, - expectedEndpoints); - - TestCase asyncCase = new TestCase<>(createClient(EndpointDiscoveryRequiredWithCustomizationTestAsyncClient.builder().endpointDiscoveryEnabled(endpointDiscoveryEnabled), - endpointOverridden), - c -> c.testDiscoveryRequired(r -> {}).join(), - caseName(EndpointDiscoveryRequiredWithCustomizationTestAsyncClient.class, endpointDiscoveryEnabled, endpointOverridden, expectedEndpoints), - true, - expectedEndpoints); - - return Arrays.asList(syncCase, asyncCase); - } - - private static T createClient(SdkClientBuilder clientBuilder, - boolean endpointOverridden) { - return clientBuilder.applyMutation(c -> addEndpointOverride(c, endpointOverridden)) - .overrideConfiguration(c -> c.retryPolicy(p -> p.numRetries(0)) - .addExecutionInterceptor(new EndpointCapturingInterceptor())) - .build(); - } - - private static String caseName(Class client, - boolean endpointDiscoveryEnabled, - boolean endpointOverridden, - String... expectedEndpoints) { - return "(Client=" + client.getSimpleName() + - ", DiscoveryEnabled=" + endpointDiscoveryEnabled + - ", EndpointOverridden=" + endpointOverridden + - ") => (ExpectedEndpoints=" + Arrays.toString(expectedEndpoints) + ")"; - } - - private static void addEndpointOverride(SdkClientBuilder builder, boolean endpointOverridden) { - if (endpointOverridden) { - builder.endpointOverride(URI.create(ENDPOINT_OVERRIDE)); - } - } - - private static class TestCase { - private final T client; - private final Consumer methodCall; - private final String caseName; - private final boolean enforcePathOrder; - private final String[] expectedPaths; - - private TestCase(T client, Consumer methodCall, String caseName, boolean enforcePathOrder, String... expectedPaths) { - this.client = client; - this.methodCall = methodCall; - this.caseName = caseName; - this.enforcePathOrder = enforcePathOrder; - this.expectedPaths = expectedPaths; - } - - private void callClient() { - methodCall.accept(client); - } - - @Override - public String toString() { - return caseName; - } - } - - private static class EndpointCapturingInterceptor implements ExecutionInterceptor { - private static final List ENDPOINTS = Collections.synchronizedList(new ArrayList<>()); - - @Override - public void beforeTransmission(Context.BeforeTransmission context, ExecutionAttributes executionAttributes) { - ENDPOINTS.add(context.httpRequest().getUri().toString()); - } - - private static void reset() { - ENDPOINTS.clear(); - } - } -} diff --git a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/EndpointDiscoveryTest.java b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/EndpointDiscoveryTest.java index 3a78b0e356a9..50fdd40116a7 100644 --- a/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/EndpointDiscoveryTest.java +++ b/test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/EndpointDiscoveryTest.java @@ -34,7 +34,6 @@ import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; import software.amazon.awssdk.core.endpointdiscovery.EndpointDiscoveryFailedException; import software.amazon.awssdk.core.exception.SdkClientException; -import software.amazon.awssdk.core.internal.SdkInternalTestAdvancedClientOption; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.endpointdiscoverytest.EndpointDiscoveryTestAsyncClient; import software.amazon.awssdk.services.endpointdiscoverytest.EndpointDiscoveryTestClient; @@ -56,8 +55,6 @@ public void setupClient() { .region(Region.US_EAST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .endpointDiscoveryEnabled(true) - .overrideConfiguration(c -> c.putAdvancedOption( - SdkInternalTestAdvancedClientOption.ENDPOINT_OVERRIDDEN_OVERRIDE, false)) .build(); asyncClient = EndpointDiscoveryTestAsyncClient.builder() @@ -65,8 +62,6 @@ public void setupClient() { .region(Region.US_EAST_1) .endpointOverride(URI.create("http://localhost:" + wireMock.port())) .endpointDiscoveryEnabled(true) - .overrideConfiguration(c -> c.putAdvancedOption( - SdkInternalTestAdvancedClientOption.ENDPOINT_OVERRIDDEN_OVERRIDE, false)) .build(); } @@ -74,7 +69,8 @@ public void setupClient() { public void syncRequiredOperation_EmptyEndpointDiscoveryResponse_CausesEndpointDiscoveryFailedException() { stubEmptyResponse(); assertThatThrownBy(() -> client.testDiscoveryRequired(r -> {})) - .isInstanceOf(EndpointDiscoveryFailedException.class); + .isInstanceOf(EndpointDiscoveryFailedException.class) + .hasCauseInstanceOf(IllegalArgumentException.class); } @Test @@ -97,7 +93,8 @@ public void syncRequiredOperation_NonRetryableEndpointDiscoveryResponse_CausesEn public void asyncRequiredOperation_NonRetryableEndpointDiscoveryResponse_CausesEndpointDiscoveryFailedException() { stubDescribeEndpointsResponse(404); assertAsyncRequiredOperationCallThrowable() - .isInstanceOf(EndpointDiscoveryFailedException.class); + .isInstanceOf(EndpointDiscoveryFailedException.class) + .hasCauseInstanceOf(EndpointDiscoveryTestException.class); } @Test