Remove resolveClientEndpointProvider from AwsDefaultClientBuilder - #7186
Conversation
This fallback method was triggering GeneratedServiceMetadataProvider initialization (~350ms) during every client creation because AttributeMap.build() eagerly resolves all lazy values including lazyOptionIfAbsent fallbacks. All generated clients have set CLIENT_ENDPOINT_PROVIDER themselves since SDK 2.27.16. Added null validation with clear error message for custom clients that don't set it
| <groupId>software.amazon.awssdk</groupId> | ||
| <artifactId>s3</artifactId> | ||
| <version>2.20.136</version> <!-- Pre-SRA version --> | ||
| <version>2.28.1</version> |
There was a problem hiding this comment.
Could you elaborate on why these tests are failing? I would also like to understand when a customer would hit this. Does the failure occur when someone uses a service client from 2.20.136 together with the newer core modules, which is what this test module sets up? In other words, what exactly exposes the backward incompatibility and whats the error message?
If we have decided that this break is acceptable for 2.20.136, then I think we need to do two things to address it correctly. First, we should either remove the test/old-client-version-compatibility-test module, since we no longer expect compatibility, or keep it and assert the failure as the expected behavior. Second, we should announce this breaking change usign github announcement (this can be done just before releasing the feature)
Motivation and Context
This PR has two changes:
AwsDefaultClientBuilder.resolveClientEndpointProvider() was triggering GeneratedServiceMetadataProvider initialization (~350ms) during every client creation. Although registered via lazyOptionIfAbsent as a fallback for older clients, AttributeMap.build() eagerly resolves all lazy values — causing the fallback to execute even when the generated builder already set CLIENT_ENDPOINT_PROVIDER. All generated clients have set it themselves since 2024, making this fallback dead code with a significant performance cost.
Additionally, AwsClientEndpointProvider.build() is the method that calls ServiceMetadata.of() and triggers the expensive initialization. After our changes across PRs #7094, #7105, #7110, #7168, no code path in client creation calls it anymore. Deprecating it signals to not use and use resolveFromOverrides() + service EndpointProvider instead, and prevents accidental re-introduction of the performance issue.
Modifications
Testing
Screenshots (if appropriate)
Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License